Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add incompatible async_hooks fns for backward compat #3433

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/node/async_hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you say "cannot remove them" do you mean "cannot not add them"?
They are not currently in workerd but we are going to remove them from unenv.
Is that right?

//
// 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;
Expand Down
Loading