blitz-js / next-superjson-plugin

SuperJSON Plugin for Next.js Pages and Components
192 stars 13 forks source link

Dev/Build thread panic error introduced with v0.6.2 #102

Closed nicolo-tito closed 4 months ago

nicolo-tito commented 5 months ago

Verify Next.js canary release

Describe the bug

Upgrading from 0.6.1 to 0.6.2 introduced this bug that prevent execution both during next dev and next build:

With next.js 14.1.0: thread '' panicked at C:\Users\Administrator.cargo\registry\src\index.crates.io-6f17d22bba15001f\rkyv-0.7.42\src\impls\core\mod.rs:267:17: assertion failed: !result.is_null()

With latest canary release: thread '' panicked at C:\Users\Administrator.cargo\registry\src\index.crates.io-6f17d22bba15001f\wasmer-wasix-0.18.0\src\runtime\task_manager\tokio.rs:105:19: there is no reactor running, must be called from the context of a Tokio 1.x runtime

Expected behavior

Dev and Build running without error

Reproduction link

No response

Version

14.1.0 and 14.1.1-canary.52

Config

const nextConfig = {
  output: 'standalone',
  experimental: {
    swcPlugins: [['next-superjson-plugin', {}]]
  }
}


### Additional context

Operating System:
Platform: win32
Arch: x64
Version: Windows 11 Pro
Binaries:
Node: 20.11.0
npm: N/A
Yarn: N/A
pnpm: N/A
Relevant Packages:
next: 14.1.1-canary.52 // Latest available version is detected (14.1.1-canary.52).
eslint-config-next: 14.1.0
react: 18.2.0
react-dom: 18.2.0
typescript: 5.3.3
Next.js Config:
output: standalone
orionmiz commented 5 months ago

Have you tried to remove your build cache?

nicolo-tito commented 5 months ago

Yes, I deleted the .next folder and tried to build from scratch more than once. If it's relevant, with canary I had to npm install --force because the .next js canary version is not compatible with the plugin dependency .next version.

miguelBinpar commented 5 months ago

Same here, we had to rollback to v0.6.1 In my case with Next.js 14.1.0

orionmiz commented 5 months ago

It depends on the upstream issue below.

@miguelBinpar Please update your next.js version to the canary.

miguelBinpar commented 5 months ago

Updated to:

And still getting same error when running dev script:

 ⨯ ./node_modules/.pnpm/next@14.1.1-canary.54_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/client/next-dev.js
Error: failed to process there is no reactor running, must be called from the context of a Tokio 1.x runtime
kletse commented 4 months ago

Have the same issue as miguelBinpar

ahkhanjani commented 4 months ago

Until this gets fixed, if you really have to, the last working version currently is 14.1.1-canary.51.

hmongdev commented 4 months ago

Currently building the Real-Time Messenger Clone and ran into this issue.

next: 14.1.0
next-superjson: 0.0.4
next-superjson-plugin: 0.6.2
avarayr commented 4 months ago

npm install next-superjson-plugin@0.6.1 --save-exact

Make sure to --save-exact otherwise you will get errors!

orionmiz commented 4 months ago

The upstream issue was resolved.

Please try again with both updated(v0.6.3) plugin and next.js canary release.

avarayr commented 4 months ago

@orionmiz hey thank you for updating the deps. at least for me, the issue is still not resolved 😔

rm -rf ./node_modules
rm -rf ./.next
npm i next-superjson-plugin@0.6.3

npm run build

Error


> next_project@0.1.0 build
> next build

   ▲ Next.js 14.1.1
   - Environments: .env
   - Experiments (use at your own risk):
     · swcPlugins
     · instrumentationHook

   Creating an optimized production build ...

thread 'thread '<unnamed><unnamed>' panicked at ' panicked at /Users/geist/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc-0.270.18/src/plugin.rs/Users/geist/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc-0.270.18/src/plugin.rs::162:14:
failed to invoke plugin: failed to invoke plugin on 'Some("/Users/avarayr/Projects/next_project/app/src/instrumentation.ts")'

Caused by:
    0: failed to invoke `/Users/avarayr/Projects/next_project/app/node_modules/next-superjson-plugin/dist/next_superjson.wasm` as js transform plugin at /Users/avarayr/Projects/next_project/app/node_modules/next-superjson-plugin/dist/next_superjson.wasm
    1: RuntimeError: call stack exhausted162
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
:14:
failed to invoke plugin: failed to invoke plugin on 'Some("/Users/avarayr/Projects/next_project/app/node_modules/next/dist/pages/_document.js")'

Caused by:
    0: failed to invoke `/Users/avarayr/Projects/next_project/app/node_modules/next-superjson-plugin/dist/next_superjson.wasm` as js transform plugin at /Users/avarayr/Projects/next_project/app/node_modules/next-superjson-plugin/dist/next_superjson.wasm
    1: RuntimeError: out of bounds memory access
sh: line 1: 21857 Segmentation fault: 11  next build

Running with RUST_BACKTRACE=full

Stack backtrace:
   0: _napi_register_module_v1
   1: _napi_register_module_v1
   2: _BrotliDecoderVersion
   3: _BrotliDecoderVersion
   4: _BrotliDecoderVersion
   5: _BrotliDecoderVersion
   6: _BrotliDecoderVersion
   7: <unknown>
   8: _BrotliDecoderVersion
   9: _BrotliDecoderVersion
  10: _BrotliDecoderVersion
  11: _BrotliDecoderVersion
  12: <unknown>
  13: <unknown>
  14: <unknown>
  15: <unknown>
  16: <unknown>
  17: <unknown>
  18: <unknown>
stack backtrace:
   0:        0x16415d0d8 - _napi_register_module_v1
   1:        0x164181dac - _napi_register_module_v1
   2:        0x16415957c - _napi_register_module_v1
   3:        0x16415cf14 - _napi_register_module_v1
   4:        0x16415e63c - _napi_register_module_v1
   5:        0x16415e384 - _napi_register_module_v1
   6:        0x16415ea64 - _napi_register_module_v1
   7:        0x16415e964 - _napi_register_module_v1
   8:        0x16415d540 - _napi_register_module_v1
   9:        0x16415e700 - _napi_register_module_v1
  10:        0x1642bef3c - _napi_register_module_v1
  11:        0x1642bf2dc - _napi_register_module_v1
  12:        0x162ccfb7c - _BrotliDecoderVersion
  13:        0x162ccbae8 - _BrotliDecoderVersion
  14:        0x160185c6c - <unknown>
  15:        0x162dbc97c - _BrotliDecoderVersion
  16:        0x162dbc8a4 - _BrotliDecoderVersion
  17:        0x162e86b10 - _BrotliDecoderVersion
  18:        0x162e912f8 - _BrotliDecoderVersion
  19:        0x160040710 - <unknown>
  20:        0x160041b78 - <unknown>
  21:        0x160040a8c - <unknown>
  22:        0x160042ad0 - <unknown>
  23:        0x16017b46c - <unknown>
  24:        0x160042678 - <unknown>
  25:        0x16017a2e0 - <unknown>
sh: line 1: 24383 Segmentation fault: 11  next build

(looking at the log - I have instrumentation hook experiment turned on, however deleting the instrumentation hook and disabling it still produces similar error, so that's not the culprit)

orionmiz commented 4 months ago

@avarayr As the error message shows, it doesn't seem to be the next.js canary version. According to the release notes, 14.1.1 is a backport release not containing the swc fix patches above.

5war00p commented 4 months ago

Yup if its not canary it didnt work for me too. But the --save-exact that @avarayr suggested with 0.6.1 works fine.

nicolo-tito commented 4 months ago

The upstream issue was resolved.

* [fix(next-swc): Provide tokio context required for WASM plugins vercel/next.js#62441](https://github.com/vercel/next.js/pull/62441)

Please try again with both updated(v0.6.3) plugin and next.js canary release.

Thanks @orionmiz, I can confirm the application is building correctly with latest canary 14.1.2-canary.2 and next-superjson-plugin 0.6.3. For people arriving here later: using @avarayr solution with --save-exact means to use exactly the specified version, in this case 0.6.1 (where the error didn't occur yet), same as:

"dependencies": {
  "next-superjson-plugin": "0.6.1",
}

in package.json. When current next.js canary will be released in stable, you can update next-superjson-plugin version with npm install next-superjson-plugin to avoid being stuck on 0.6.1.

barrynorman commented 4 months ago

@nicolo-tito I'm currently on Next Js 14.1.1 and next-superjson-plugin 0.6.3 but I still get

[1]    49917 bus error  pnpm run build
nicolo-tito commented 4 months ago

@nicolo-tito I'm currently on Next Js 14.1.1 and next-superjson-plugin 0.6.3 but I still get

[1]    49917 bus error  pnpm run build

Please notice that I tested it on latest canary 14.1.2-canary.2: as specified here https://github.com/blitz-js/next-superjson-plugin/issues/102#issuecomment-1975070603 next.js 14.1.1 doesn't include the last canary fixes, so I guess we will need to wait 14.1.2 for it to be working on the stable channel

barrynorman commented 4 months ago

@nicolo-tito I'm currently on Next Js 14.1.1 and next-superjson-plugin 0.6.3 but I still get

[1]    49917 bus error  pnpm run build

Please notice that I tested it on latest canary 14.1.2-canary.2: as specified here #102 (comment) next.js 14.1.1 doesn't include the last canary fixes, so I'll guess we will need to wait 14.1.2 for it to be working on the stable channel

Oh. I read over it. Sorry. And Thanks ^^

justinh00k commented 3 months ago

I am getting this error on 14.1.4. Should this now be working on stable?

avarayr commented 3 months ago

I am getting this error on 14.1.4. Should this now be working on stable?

Nope, 14.2 when it comes out..meanwhile stay on next-superjson-plugin@0.6.1

miguelBinpar commented 3 months ago

Everything working fine for me with next@14.2.0 and next-superjson-plugin@0.6.3