-
Notifications
You must be signed in to change notification settings - Fork 335
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
base: main
Are you sure you want to change the base?
Conversation
@jasnell just fyi: we need to land this pull-request before the next release, if we don't want to introduce a breaking change. |
// 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. |
There was a problem hiding this comment.
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?
we discussed and not going to add unenv-only stuff to the runtime just for backwards compat. will find other way. |
Can we leave them in unenv and then have a breaking change Wrangler major release in the future where we also drop them from unenv (and/or drop unenv altogether). |
bingo! ^^ this |
Please let's not push wrangler releases that break existing code for any reason. We have a compat flag system, we can use it. |
To summarize where we have landed in internal discussions around this:
As long as we follow this approach, it is ok if the runtime implementation of an API does not match the polyfill-injected implementation of the API and such differences would not be considered breaking changes, making this PR unnecessary. Instead, when implementing the APIs in directly in the runtime we will focus only on implementing the behavior that is correct to ensure compatibility with Node.js and not compatibility with unenv. To @kentonv's point... wrangler will need to ensure that such updates are done in a way that does not become a burden on users to reconcile. Compat flags in wrangler could help minimize the risk of breaks when transitioning between a polyfill-injected API and a runtime-provided API. If done properly, that can be handled entirely in the tooling without the need to add a bunch of new compat flag combinations to the runtime itself. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the above discussion, this PR shouldn't land. Aligning the built-in impl with the polyfill impl is not goal.
So revert #3432? |
Some thoughts here: The extra functions are a bug in We could make sure I think the correct fix this would be to extend the |
The following methods are defined in unenv even though they are not defined in Node.js. This is due to a bug. AsyncHook class doesn't have these functions, but async hook callbacks does. Please take a look into Node.js documentation for async_hooks
In order to preserve backward compatibility and not introduce a breaking change on applications that depend on this functions (even though they are not doing anything), we have to implement them in workerd as well.
The issue is tracked on unjs/unenv#403 but removing these functions will be a breaking change, and wrangler still needs to provide these methods regardless of it's been removed from unenv or not. (Unless we remove polyfill and depend on async_hooks implementation of workerd, rather than the polyfill)
In a follow up pull-request, I'll add logging for these functions to track the usage over time. It won't be 100% correct, but it will give us an estimation about whether or not this is used in workers.
cc @IgorMinar @irvinebroque @jasnell @danlapid @vicb