From 87b73a8dbf99d4ccd60134925e832be4ae2c3f36 Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Wed, 29 Jan 2025 14:19:51 -0500 Subject: [PATCH] add incompatible async_hooks fns for backward compat --- src/node/async_hooks.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/node/async_hooks.ts b/src/node/async_hooks.ts index e0a0fc2fe3f..2f84f360922 100644 --- a/src/node/async_hooks.ts +++ b/src/node/async_hooks.ts @@ -13,6 +13,22 @@ class AsyncHook { public disable(): this { return this; } + + // IMPORTANT + // + // The following methods were defined in unenv while they don't exist in Node.js + // async_hooks module. This is a bug with unenv. + // Unfortunately, unless we are 100% sure these methods are not used in production, + // we can not remove them from workerd. + // + // More information about the bug is available at https://github.com/unjs/unenv/issues/403 + // + // Ref: https://github.com/unjs/unenv/blob/ada7c4093c69c9729f1b008a8ab7902389941624/src/runtime/node/async_hooks/internal/async-hook.ts#L25 + public init(): void {} + public before(): void {} + public after(): void {} + public destroy(): void {} + public promiseResolve(): void {} } export const { AsyncLocalStorage, AsyncResource } = async_hooks;