Skip to content
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

SWC download fails because of a missing trailing slash in the custom registry #39419

Closed
1 task done
ghostd opened this issue Aug 9, 2022 · 1 comment · Fixed by #39427
Closed
1 task done

SWC download fails because of a missing trailing slash in the custom registry #39419

ghostd opened this issue Aug 9, 2022 · 1 comment · Fixed by #39427
Labels
bug Issue was opened via the bug report template.

Comments

@ghostd
Copy link

ghostd commented Aug 9, 2022

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP Wed Mar 2 18:50:46 UTC 2022
Binaries:
  Node: 14.18.2
  npm: 6.14.15
  Yarn: 1.22.15
  pnpm: N/A
Relevant packages:
  next: 12.2.4
  eslint-config-next: N/A
  react: 17.0.2
  react-dom: 17.0.2

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

While building the production site (with "next build") on our CI, I get this error:

info  - Creating an optimized production build...
info  - Downloading WASM swc package...
warn  - Attempted to load @next/swc-linux-x64-gnu, but it was not installed
warn  - Attempted to load @next/swc-linux-x64-gnux32, but it was not installed
warn  - Attempted to load @next/swc-linux-x64-musl, but it was not installed
warn  - Error: request failed with status 404
    at /builds/xxx/node_modules/next/dist/lib/download-wasm-swc.js:124:23
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async Object.downloadWasmSwc (/builds/xxx/node_modules/next/dist/lib/download-wasm-swc.js:122:9)
    at async /builds/xxx/node_modules/next/dist/build/swc/index.js:114:13
error - Failed to load SWC binary for linux/x64, see more info here: https://nextjs.org/docs/messages/failed-loading-swc

After digging, I found npm config get registry can return a value without a trailing slash, something like : http://artifactory.private.domain/artifactory/api/npm/all-npm

And the download code assumes a trailing slash:

let registry = `https://registry.npmjs.org/`
try {
const output = execSync('npm config get registry').toString().trim()
if (output.startsWith('http')) {
registry = output
}
} catch (_) {}
await fetch(`${registry}${pkgName}/-/${tarFileName}`).then((res) => {

Expected Behavior

Since I cannot change the npm settings on my CI, i wonder if the NextJs script can be more resilient by checking the result of the command npm config get registry: if the string does not end with a /, it adds it before calling fetch

Link to reproduction

none

To Reproduce

Have npm settings with a custom URL registry without the trailing slash.
Build the production bundle.

@ghostd ghostd added the bug Issue was opened via the bug report template. label Aug 9, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Sep 9, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant