DEP0098:AsyncHooks 嵌入器 AsyncResource.emitBefore 和 AsyncResource.emitAfter API


🌐 DEP0098: AsyncHooks embedder AsyncResource.emitBefore and AsyncResource.emitAfter APIs

类型:寿命终止

🌐 Type: End-of-Life

AsyncHooks 提供的嵌入式 API 暴露了 .emitBefore().emitAfter() 方法,这些方法很容易被错误使用,可能导致无法恢复的错误。

🌐 The embedded API provided by AsyncHooks exposes .emitBefore() and .emitAfter() methods which are very easy to use incorrectly which can lead to unrecoverable errors.

请改用 asyncResource.runInAsyncScope() API,它提供了更安全、更方便的替代方案。详见 https://github.com/nodejs/node/pull/18513