v134 · javascript
Explicit resource management (async)
This feature addresses a common pattern in software development regarding the lifetime and management of various resources (memory, I/O, etc.). This pattern generally includes the allocation of a resource and the ability to explicitly release critical resources.
concepts
-
await using
await using statement for async disposal. Mirrors using for sync resources.
-
Async transaction
The DB-transaction motivating case: commit on the happy path, rollback on throw, automatic — driven by Symbol.asyncDispose.
-
AsyncDisposableStack
Instrumented async pipeline. Acquire temp file, token, db lock, queue message — pick which step fails and watch the stack unwind disposers in LIFO order.
-
Async Resource Monitor
Live resource tracker: open DB connections, file handles, HTTP clients, cache buckets with await using. Pick a scenario (happy path, mid-scope throw, AsyncDisposableStack, partial acquire) and watch open/disposed state update in real time.
-
Streaming pipeline
AsyncDisposableStackmanaging a 4-stage HTTP → decoder → transformer → writer pipeline. Run four scenarios: happy path, throw in transformer, throw in decoder, and cancel mid-stream. The stack unwinds in LIFO order in every case — animated pipeline diagram shows each stage's open/disposed state.
why it shipped
https://github.com/tc39/proposal-explicit-resource-management/blob/main/README.md