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


类型: 生命结束

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

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

Type: End-of-Life

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

Use asyncResource.runInAsyncScope() API instead which provides a much safer, and more convenient, alternative. See https://github.com/nodejs/node/pull/18513.