This feature is not Baseline because it does not work in some of the most widely-used browsers.
The AsyncDisposableStack object represents a stack of async disposers to run when the stack itself is disposed. Disposer functions are executed in reverse order of registration, with strong error handling guarantees. Calling its move() method will transfer responsibility for calling the current registered disposers to a new AsyncDisposableStack and prevent registering any additional disposers.
See DisposableStack for general information about using disposable stacks.
AsyncDisposableStack()Creates a new AsyncDisposableStack object.
These properties are defined on AsyncDisposableStack.prototype and shared by all AsyncDisposableStack instances.
AsyncDisposableStack.prototype.constructorThe constructor function that created the instance object. For AsyncDisposableStack instances, the initial value is the AsyncDisposableStack constructor.
AsyncDisposableStack.prototype.disposedRead-only. Returns true if the AsyncDisposableStack has been disposed, or false if not.
AsyncDisposableStack.prototype[Symbol.toStringTag]The initial value of the [Symbol.toStringTag] property is the string "AsyncDisposableStack". This property is used in Object.prototype.toString().
AsyncDisposableStack.prototype.adopt()Registers a value that doesn't implement the async disposable protocol to the stack by providing a custom disposer function.
AsyncDisposableStack.prototype.disposeAsync()Disposes this stack by calling all disposers registered to it in reverse order of registration.
AsyncDisposableStack.prototype.defer()Takes a callback function to be called when the stack is disposed.
AsyncDisposableStack.prototype.move()Creates a new AsyncDisposableStack instance that contains the same disposers as this stack, and then marks this stack as disposed, without calling any disposers.
AsyncDisposableStack.prototype.use()Registers a value that implements the async disposable protocol to the stack.
AsyncDisposableStack.prototype[Symbol.asyncDispose]An alias for the disposeAsync() method.
| Desktop | Mobile | Server | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | Bun | Deno | Node.js | |
@@asyncDispose |
134 | 134 | 141 | 119 | No | 134 | 141 | 88 | No | 29.0 | 134 | No | 1.3.0 | 2.2.10 | 24.0.0 |
AsyncDisposableStack |
134 | 134 | 141 | 119 | No | 134 | 141 | 88 | No | 29.0 | 134 | No | 1.3.0 | 2.2.10 | 24.0.0 |
AsyncDisposableStack |
134 | 134 | 141 | 119 | No | 134 | 141 | 88 | No | 29.0 | 134 | No | 1.3.0 | 2.2.10 | 24.0.0 |
adopt |
134 | 134 | 141 | 119 | No | 134 | 141 | 88 | No | 29.0 | 134 | No | 1.3.0 | 2.2.10 | 24.0.0 |
defer |
134 | 134 | 141 | 119 | No | 134 | 141 | 88 | No | 29.0 | 134 | No | 1.3.0 | 2.2.10 | 24.0.0 |
disposeAsync |
134 | 134 | 141 | 119 | No | 134 | 141 | 88 | No | 29.0 | 134 | No | 1.3.0 | 2.2.10 | 24.0.0 |
disposed |
134 | 134 | 141 | 119 | No | 134 | 141 | 88 | No | 29.0 | 134 | No | 1.3.0 | 2.2.10 | 24.0.0 |
move |
134 | 134 | 141 | 119 | No | 134 | 141 | 88 | No | 29.0 | 134 | No | 1.3.0 | 2.2.10 | 24.0.0 |
use |
134 | 134 | 141 | 119 | No | 134 | 141 | 88 | No | 29.0 | 134 | No | 1.3.0 | 2.2.10 | 24.0.0 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncDisposableStack