-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[fix] don't polyfill undici if using Deno or Bun #8338
Conversation
🦋 Changeset detectedLatest commit: c55bdca The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
I find the version sniffing a little unpleasant. And, especially since we were already pinning to a specific Undici version before because of problems we were running into, it might potentially cause breakages in people's apps if we deferred to whatever version were built into their version of Node. What if we just checked for |
That could work too. I don't have strong feelings about one vs the other, so went ahead and changed it as you suggested |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Applying the fix allowed me to start my app in dev mode with
Minimal repo https://github.com/jakubdonovan/deno-sveltekit |
if (!globalThis.process?.versions?.node) { | ||
return; | ||
} |
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.
Hey folks, Bartek from the Deno team here. This fix won't work - when executing code from npm packages we are injecting globals like process
or setImmediate
behind the scenes, if we didn't do that most of packages wouldn't work as they often rely on process
global. I suggest to do typeof globalThis.Deno !== "undefined"
check instead
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.
The error reported in #8338 (comment) is caused by this check
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.
@bartlomieju thanks! I had tested process.versions.node
directly and not through an npm package. I'm curious, what do you set process.versions.node
to? I wonder if my earlier solution of polyfilling only when the version is less than 18.11.0 might work for Deno
For Bun, either
|
Thanks @Jarred-Sumner. I'm curious, what do you set the Node version to? Would it be something similar to Node like 20.0.2 or more like a fake value like 100.0.0 or 1.0.0 or something? I wonder if my earlier solution of polyfilling only when the version was less than 18.11.0 might work for Bun |
Sounds like we should have a blacklist (check who shouldn't get the polyfill, e.g. bun and deno) instead of a whitelist (check for node) either way. |
Seems to me the environment detection should happen at the relevant |
I had debated that. I did it this way to reduce the amount of code required and also because it'd probably allow |
People using As this PR stands we'd be adding the detection code to Netlify and Vercel apps (plus any community adapters that use the polyfills), quite unnecessarily. It doesn't belong inside the function |
Fixes #8324