-
Notifications
You must be signed in to change notification settings - Fork 146
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
Show error which occurs in vercel/vercel ci tests #447
Show error which occurs in vercel/vercel ci tests #447
Conversation
@@ -0,0 +1 @@ | |||
const URLParser = typeof window === 'undefined' ? URL : 'b' |
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.
This test fails with
TypeError: Class constructor URL cannot be invoked without 'new'
The offending node is the URL Identifier
, and I'm not able to see where it's getting invoked, I'm guessing due to some async nature of the code.
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.
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.
More info on this:
- The URL global you linked does seem to be the culprit!
- Removing URL from globals makes this case work, but breaks other cases
- The core problem exists well before
0.27.4
, but0.27.4
seems to trace more files which causes our test to hit this URL core problem now
Debugging this is tricky since the stack trace is very unhelpful. For example, replacing URL: URL
with URL: () => console.trace('Called URL')
and running this reproduction test gives the very unhelpful stack trace:
Trace: Called URL
at Object.URL [as then] (/Users/onsclom/projects/nft/src/analyze.ts:188:13)
I can't figure out where URL is getting called from. Seems like from the then
of some promise, but which one?
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.
@styfle Do you know how URL is getting invoked here? Happy to make a PR fixing this, but stuck on finding where exactly URL is getting invoked.
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.
Its probably from computePureStaticValue()
which is basically a static analysis form of eval()
so it sets globals vars and local vars to try to compute a value.
Line 459 in b3d2da0
async function computePureStaticValue(expr: Node, computeBranches = true) { |
`nodeFileTrace` errors on `const URLParser = typeof window === 'undefined' ? URL : 'b'` with `TypeError: Class constructor URL cannot be invoked without 'new'`. This is because this code: ```ts async function ConditionalExpression() { return { test: 'foo', then: URL, else: 'bar', }; } await ConditionalExpression(); ``` calls `URL()` since `ConditionalExpression` is an async function returning a [thenable](https://masteringjs.io/tutorials/fundamentals/thenable). Solution: rename all `.then` fields to `.ifTrue` since `then` is reserved for thenables. Closes #447
We're seeing an error with
0.27.4
in our tests while trying to upgradehttps://github.com/vercel/vercel/actions/runs/11487918780/job/31973631387?pr=12109
I was able to isolate it down to this code snippet. Which is from an admittedly old module depended upon by Next version 9
https://www.npmjs.com/package/normalize-url/v/3.3.0?activeTab=code