close method

Future<void> close()

Closes the scope and runs all disposers in reverse order.

Safe to call multiple times, and a second call JOINS the first rather than returning early. Returning early is a race: the scope self-closes on cancellation and on deadline, so a teardown that cancelled the token first would find _isClosed set and continue — leaving the disposers running detached behind it, and RpcResponderEndpoint.close() returning before the handler's cleanup had finished. The disposer loop is bounded per disposer, so joining cannot hang: see disposerTimeout.

Implementation

Future<void> close() => _closing ??= _close();