Async context

asyncLocalStorage.disable()

Disables this instance and exits its linked contexts. Use at the end of the lifetime of an instance, not after each request in a shared server. In Node 22 the method is experimental. Tested on Node.js 22.16.0. Example output (one line per entry): ["active", "true"].

Formal Syntax & Structure

nodejs syntaxnodejs
asyncLocalStorage.disable()

Return Value

undefined

No return value.

Working Example

Example Snippetnodejs
import { AsyncLocalStorage } from 'node:async_hooks';const als = new AsyncLocalStorage();als.run('active', () => { console.log(als.getStore()); als.disable(); console.log(als.getStore() === undefined); });
Node.js Reference