-
Notifications
You must be signed in to change notification settings - Fork 17
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: handle process.version
set to undefined
#78
Conversation
index.js
Outdated
if (typeof EdgeRuntime === "string") { | ||
return "Edge Runtime"; | ||
} |
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.
I don't feel too comfortable to start adding vendor-specific code. Could you for now leave that out and we discuss it in an issue? Maybe we can find another way
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.
For sure, removed
process.version
set to undefined
🎉 This PR is included in version 7.0.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Vercel's [Edge Runtime](https://edge-runtime.vercel.app/) is not Node.js, but will have a global `process` defined
Vercel's [Edge Runtime](https://edge-runtime.vercel.app/) is not Node.js, but will have a global `process` defined Co-authored-by: Jascha Ephraim <[email protected]>
Resolves #77
Related vercel/next.js#54739
The Edge Runtime is not Node.js, but will have a global
process
defined. Most properties ofprocess
will be present but undefined, so"version" in process
will be true. This will currently lead to a false identification as Node.js, and an error when callingprocess.version.substr(1)
. This PR instead checks thatprocess.version !== undefined
.It also will check if
typeof EdgeRuntime === "string"
, which is how the Edge environment is checked in Vercel, and then return user agent "Edge Runtime" (which is not standard in any way, but possibly better than nothing). When a request is actually sent from a Vercel Edge function it has the user agent "Next.js Middleware", but I don't see anyway to detect that specifically.Let me know if you'd like me to remove this detection of the Edge Runtime and just fall back to
<environment undetectable>
.