asyncLocalStorage.disable()


稳定性: 1 - 实验性

禁用 AsyncLocalStorage 的实例。之后对 asyncLocalStorage.getStore() 的所有调用都会返回 undefined,直到再次调用 asyncLocalStorage.run()asyncLocalStorage.enterWith()

【Disables the instance of AsyncLocalStorage. All subsequent calls to asyncLocalStorage.getStore() will return undefined until asyncLocalStorage.run() or asyncLocalStorage.enterWith() is called again.】

调用 asyncLocalStorage.disable() 时,与该实例关联的所有当前上下文将被退出。

【When calling asyncLocalStorage.disable(), all current contexts linked to the instance will be exited.】

asyncLocalStorage 可以被垃圾回收之前,必须调用 asyncLocalStorage.disable()。这不适用于 asyncLocalStorage 提供的存储,因为这些对象会随着相应的异步资源一起被垃圾回收。

【Calling asyncLocalStorage.disable() is required before the asyncLocalStorage can be garbage collected. This does not apply to stores provided by the asyncLocalStorage, as those objects are garbage collected along with the corresponding async resources.】

当当前进程中不再使用 asyncLocalStorage 时,请使用此方法。

【Use this method when the asyncLocalStorage is not in use anymore in the current process.】