Repository navigation
test: stop next-auth.test.ts from waiting on the npm registry while next dev starts #46477
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,6 +46,13 @@ function test(port) { | |
| }); | ||
| } | ||
|
|
||
| // `next dev` waits for this with no timeout, only to report whether it is out of date. | ||
| const { fetch } = globalThis; | ||
| globalThis.fetch = (input, init) => | ||
| String(input?.url ?? input).startsWith("https://registry.npmjs.org/") | ||
| ? Promise.reject(new Error("no public internet in tests")) | ||
| : fetch(input, init); | ||
|
Comment on lines
+51
to
+54
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: sed -n '1,240p' test/js/third_party/next-auth/next-auth.test.ts
printf '\n--- fixture server ---\n'
sed -n '1,140p' test/js/third_party/next-auth/fixture/server.js
printf '\n--- relevant references ---\n'
rg -n 'globalThis\.fetch|registry\.npmjs\.org|fixture/server|next-auth' test/js/third_party/next-auth test/AGENTS.md CLAUDE.mdRepository: oven-sh/bun Length of output: 5605 Add direct regression coverage for both fetch-wrapper branches.
🤖 Prompt for AI Agents |
||
|
|
||
| const app = next({ dev: true, dir: import.meta.dirname, quiet: true }); | ||
| const handle = app.getRequestHandler(); | ||
|
|
||
|
|
||
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.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Compare the normalized registry origin.
The raw prefix check does not block
https://registry.npmjs.orgwithout the trailing slash. Equivalent URL spellings can also bypass the check beforefetchnormalizes them. If the wrapped code supplies one of these forms, the request reaches the public registry and the startup wait can recur. Parse the URL and compare its normalizedoriginwithhttps://registry.npmjs.org.🤖 Prompt for AI Agents