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

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