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

[NEXT-939] SIGSEGV on next build with 13.2.4 #46989

Closed
1 task done
aplr opened this issue Mar 10, 2023 · 27 comments · Fixed by #48098
Closed
1 task done

[NEXT-939] SIGSEGV on next build with 13.2.4 #46989

aplr opened this issue Mar 10, 2023 · 27 comments · Fixed by #48098
Assignees
Labels
bug Issue was opened via the bug report template. SWC Related to minification/transpilation in Next.js.

Comments

@aplr
Copy link

aplr commented Mar 10, 2023

Verify canary release

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

Provide environment information

Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 22.3.0: Mon Jan 30 20:38:37 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T6000
    Binaries:
      Node: 18.13.0
      npm: 8.19.3
      Yarn: 1.22.19
      pnpm: 7.26.0
    Relevant packages:
      next: 13.2.4
      eslint-config-next: 13.2.4
      react: 18.2.0
      react-dom: 18.2.0

Which area(s) of Next.js are affected?

next build CLI

To Reproduce

I'll dig into it, maybe I can reproduce it easily. However I'd expect next build not to segfault on my existing codebase which works on 13.2.3 without changes other than upgrading next.

Describe the Bug

After upgrading next to 13.2.4, when running next build, I'm running into a segfault.

As you can see, I'm using the app dir (only). Tell me if you need more info.

$ next build --experimental-app-only
info  - Loaded env from /next/apps/web/.env.local
info  - Loaded env from /next/apps/web/.env.production
warn  - You have enabled experimental features (appDir, swcPlugins, serverComponentsExternalPackages) in next.config.mjs.
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.
info  - Thank you for testing `appDir` please leave your feedback at https://nextjs.link/app-feedback

(node:83878) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
(Use `node --trace-warnings ...` to show where the warning was created)
error Command failed with signal "SIGSEGV".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed.
Exit code: 1
Command: /user/.nvm/versions/node/v18.13.0/bin/node
Arguments: /user/.cache/node/corepack/yarn/1.22.19/lib/cli.js build
Directory: /next
Output:

info Visit https://yarnpkg.com/en/docs/cli/workspace for documentation about this command.

Expected Behavior

No Segfault when running yarn build

How are you deploying your application? (if relevant)

On Vercel, where it's also segfaulting. (Also in my Docker build)

NEXT-939

@aplr aplr added the bug Issue was opened via the bug report template. label Mar 10, 2023
@aplr aplr changed the title Segfault on next build with 13.2.4 SIGSEGV on next build with 13.2.4 Mar 10, 2023
@aplr
Copy link
Author

aplr commented Mar 10, 2023

Ok I've found the troublemaker, it's the SWC plugin @graphql-codegen/client-preset-swc-plugin. I've created an issue there: dotansimha/graphql-code-generator#9145.

It's only happening since next 13.2.4, were there any dependency updates / changes which could cause this issue?

Also, is there a way to tell where to look for such issues, i.e. better error messages so one finds the underlying cause faster?

@jinojacob15
Copy link

Same issue with me , After updating to 13.2.4 ,dev is working fine but yarn build and yarn start (prod build) gives me error

DeepinScreenshot_select-area_20230310183614

@jinojacob15
Copy link

@aplr is @graphql-codegen/client-preset-swc-plugin in built with apollo client ??. I am not using @graphql-codegen/client-preset-swc-plugin in my code i checked.

@SuttonJack
Copy link
Contributor

Getting the same error. It was introduced for me at next@13.2.4-canary.6

Version next@13.2.4-canary.5 and below all work fine

@SuttonJack
Copy link
Contributor

SuttonJack commented Mar 12, 2023

@shuding Could this stem from #46881 ? These ChunkLoadError messages in the console seem to be coming from react rather than next

Screenshot 2023-03-11 at 9 47 16 PM

One other note - this only occurs on deployment or after running next build && next start

next dev works fine

@aplr
Copy link
Author

aplr commented Mar 12, 2023

I'm not sure if the issues I and you reported in this ticket are related in any way, as I get segfaults at build-time caused by a swc plugin

@martinnabhan
Copy link
Contributor

martinnabhan commented Mar 13, 2023

I can confirm I get the same error when using next-superjson-plugin (which is a SWC plugin). If I remove the plugin from next.config.js building works again. I'll look into this some more. SWC seems to be the common link.

Edit: After testing different Next.js versions, the error seems to be introduced by 13.2.4-canary.9. I can also confirm I'm getting the same error on 13.2.5-canary.1.

Edit 2: I can confirm that in my case reverting #46971 and rebuilding @next/swc fixed the error for me.

@icyJoseph
Copy link
Contributor

Hi,

Do you guys have 32 bits architecture? or if you run node -p "process.arch", does it match your OS?

@Timothee-P
Copy link

@jinojacob15 and @SuttonJack:
The same errors occur in my project after updating next to 13.2.4. It doesn't seems related to this issue and SWC, but more to dynamic imports.
Just to let you know I have created a new issue #47173

@jinojacob15
Copy link

@Timothee-P @SuttonJack @aplr I Spent two days in debugging the issue , finally code was working when i removed dynamic imports with ssr:false .
But there was a bizarre issue that even when i downgraded the next version to 13.2.3 and still issue persisted .

@himself65
Copy link
Contributor

seems like swcPlugins won't work

@kevin-courbet
Copy link

I'm on a M2 mac and also have this issue if I have a SWC plugin enabled (next-superjson)

@yangricardo
Copy link

I'm on a M2 mac and also have this issue if I have a SWC plugin enabled (next-superjson)

Also have disabled this next-superjson-plugin. It is building with success again. In my case, i think have never worked as expected, so i am removing it.

@kdy1
Copy link
Member

kdy1 commented Mar 28, 2023

@kdy1
Copy link
Member

kdy1 commented Mar 28, 2023

The cause is a bug of rkyv which is triggerred by recent nightly rustc.

I'll check if it's possible to downgrade rustc for now.

@kdy1
Copy link
Member

kdy1 commented Mar 28, 2023

I'm checking if rkyv@0.7.40 fixes this issue.

swc-project/swc#7154

@simonknittel
Copy link

I'm having a similar issue but not quite the same.
I'm also using the next-superjson-plugin with swcPlugins. Disabling that plugin makes next build work again.
However, having the plugin enabled results for me in a different error.
Also, downgrading to 13.2.3 like you suggested is not working.

warn  - You are using a non-standard "NODE_ENV" value in your environment. This creates inconsistencies in the project and is strongly advised against. Read more: https://nextjs.org/docs/messages/non-standard-node-env
info  - Loaded env from /Users/simon.knittel/Documents/hmmh/snivy/app/.env
warn  - You have enabled experimental features (outputFileTracingRoot, swcPlugins) in next.config.js.
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.

info  - Skipping validation of types
info  - Skipping linting
info  - Creating an optimized production build .zsh: bus error  npx next build

@kdy1
Copy link
Member

kdy1 commented Mar 30, 2023

Https://github.com/swc-project/swc/pull/7163 will fix this.

I'll update turbopack and next-swc ASAP once it's merged.

darthmaim added a commit to GW2Treasures/gw2treasures.com that referenced this issue Apr 2, 2023
@darthmaim
Copy link

Hi @kdy1, what is left to fix this issue? Can the community somehow help?

@kdy1
Copy link
Member

kdy1 commented Apr 3, 2023

swc-project/swc#7170 fixed this, and vercel/turbo#4358 should be merged into turbopack first

@balazsorban44 balazsorban44 added SWC Related to minification/transpilation in Next.js. kind: bug labels Apr 4, 2023
@balazsorban44 balazsorban44 changed the title SIGSEGV on next build with 13.2.4 [NEXT-939] SIGSEGV on next build with 13.2.4 Apr 4, 2023
@tacomanator
Copy link

Also, downgrading to 13.2.3 like you suggested is not working.

@simonknittel Did you remove the .next directory? downgrading to 13.2.3 works but you need to remove .next and restart. This is working with next-superjson-plugin for me.

@himself65
Copy link
Contributor

still happened on 13.3.0

sneko added a commit to inclusion-numerique/mediature that referenced this issue Apr 17, 2023
sokra pushed a commit that referenced this issue Apr 18, 2023
Depends on vercel/turbo#4470

---

 - Closes #46989
 - Fixes WEB-879
 - Fixes WEB-813

---------

Co-authored-by: OJ Kwon <1210596+kwonoj@users.noreply.github.com>
Co-authored-by: Donny/강동윤 <kdy1997.dev@gmail.com>
Co-authored-by: Shu Ding <g@shud.in>
@himself65
Copy link
Contributor

Looks like v13.3.1-canary.12 will fix the issue

himself65 added a commit to toeverything/AFFiNE that referenced this issue Apr 18, 2023
@himself65
Copy link
Contributor

himself65 commented Apr 18, 2023

Looks like v13.3.1-canary.12 will fix the issue

I think no, swc version is too higher than most plugins

@kdy1
Copy link
Member

kdy1 commented Apr 18, 2023

Now the runtime is fixed, so plugin authors can update their plugins

@sFritsch09
Copy link

Removing sharp from dependencies worked for me!
yarn remove sharp

@github-actions
Copy link
Contributor

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 Jun 15, 2023
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. SWC Related to minification/transpilation in Next.js.
Projects
None yet
Development

Successfully merging a pull request may close this issue.