Disposes items in reverse insertion order: teardown mirrors
construction, so a resource is always disposed before whatever it was built
on top of (a render target before its device, a joint before its bodies).
Owners therefore only have to record acquisitions in order.
Every item is disposed even if an earlier one throws โ a failed dispose must
not leak the resources behind it (ยง83). If any dispose() threw, the first
thrown value is re-thrown after the pass completes. "First" is first in
reverse order, so for [a, b, c] where b and c both throw, the value
re-thrown is c's.
An entry that is not disposable at all โ null, undefined, or an object
carrying only [Symbol.dispose] โ is treated exactly like a throwing
disposer: the TypeError is captured, every remaining item is still
disposed, and the TypeError is re-thrown at the end. Calling this twice on
the same item calls dispose() twice; nothing here deduplicates, so an
implementation that is not idempotent must guard itself. All four behaviours
measured 2026-09-19 from an installed tarball.
Disposes
itemsin reverse insertion order: teardown mirrors construction, so a resource is always disposed before whatever it was built on top of (a render target before its device, a joint before its bodies). Owners therefore only have to record acquisitions in order.Every item is disposed even if an earlier one throws โ a failed dispose must not leak the resources behind it (ยง83). If any
dispose()threw, the first thrown value is re-thrown after the pass completes. "First" is first in reverse order, so for[a, b, c]wherebandcboth throw, the value re-thrown isc's.An entry that is not disposable at all โ
null,undefined, or an object carrying only[Symbol.dispose]โ is treated exactly like a throwing disposer: theTypeErroris captured, every remaining item is still disposed, and theTypeErroris re-thrown at the end. Calling this twice on the same item callsdispose()twice; nothing here deduplicates, so an implementation that is not idempotent must guard itself. All four behaviours measured 2026-09-19 from an installed tarball.