pmndrs / swc-jotai

MIT License
90 stars 14 forks source link

Crash when using with Next.js 13.4.1, 13.4.2 and 13.4.3 #13

Closed ornakash closed 1 year ago

ornakash commented 1 year ago

Added the lines to next.config.js as mentioned in the documentation. In older versions everything worked perfectly, but for some reason it doesn't work anymore.

experimental: {
    swcPlugins: [
      ["@swc-jotai/debug-label", {}],
      ["@swc-jotai/react-refresh", {}],
    ],
  },

When I try to run my application, I am getting the following error:

PS C:\or\test-app> yarn run dev yarn run v1.22.19 $ next dev

  • ready started server on 0.0.0.0:3000, url: http://localhost:3000
  • info Loaded env from C:\or\test-app.env.local
  • warn You have enabled experimental feature (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.

thread '' panicked at 'assertion failed: prev.start > max', C:\Users\runneradmin.cargo\registry\src\index.crates.io-6f17d22bba15001f\wasmer-compiler-3.2.1\src\engine\trap\frame_info.rs:224:9 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

  • error ./node_modules/next/dist/shared/lib/router/router.js Error: failed to process

Import trace for requested module: ./node_modules/next/dist/shared/lib/router/router.js

  • wait compiling... thread '' panicked at 'called Result::unwrap() on an Err value: PoisonError { .. }', C:\Users\runneradmin.cargo\registry\src\index.crates.io-6f17d22bba15001f\wasmer-compiler-3.2.1\src\engine\trap\frame_info.rs:220:39
  • error ./node_modules/next/dist/shared/lib/router/router.js Error: failed to process called Result::unwrap() on an Err value: PoisonError { .. }

Import trace for requested module: ./node_modules/next/dist/shared/lib/router/router.js

Thanks in advance

fabio-nettis commented 1 year ago

Still happens to me using Next.js v13.4.1, tried pretty much everything. I'm seeing following error in the console output:

.thread '<unnamed>' panicked at 'assertion failed: prev.start > max', /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-compiler-3.2.1/src/engine/trap/frame_info.rs:224:9

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: PoisonError { .. }', /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-compiler-3.2.1/src/engine/trap/frame_info.rs:220:39

Would really appreciate if you could take a look at this. Thank you for the effort.

Comment related to #6

KorySchneider commented 1 year ago

I am also seeing this error, but only when putting the swc configuration in my next.config.js. When moving the configuration to .swcrc I do not get the error, but the debug-label package does not work.

fabio-nettis commented 1 year ago

@KorySchneider Thats because the .swcrc file is ignored by Next.js, only configuration that is accepted resides inside the next.config.js file.

KorySchneider commented 1 year ago

@fabio-nettis The readme for swc-jotai should be updated then, as it currently says to add the plugin configuration to your .swcrc file. Or does the configuration need to be added to both .swcrc and next.config.js?

https://github.com/pmndrs/swc-jotai#usage

cc @Thisen @kdy1

KorySchneider commented 1 year ago

Either way I am still unable to get these plugins working. Here are the logs:

thread '<unnamed>' panicked at 'assertion failed: prev.start > max', /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-compiler-3.2.1/src/engine/trap/frame_info.rs:224:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: PoisonError { .. }', /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-compiler-3.2.1/src/engine/trap/frame_info.rs:220:39
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: PoisonError { .. }', /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-compiler-3.2.1/src/engine/trap/frame_info.rs:220:39
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: PoisonError { .. }', /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-compiler-3.2.1/src/engine/trap/frame_info.rs:220:39
- error ./node_modules/.pnpm/next@13.4.2_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/shared/lib/fnv1a.js
Error: failed to process

Import trace for requested module:
./node_modules/.pnpm/next@13.4.2_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/shared/lib/fnv1a.js
./node_modules/.pnpm/next@13.4.2_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/shared/lib/bloom-filter/hashing.js
./node_modules/.pnpm/next@13.4.2_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/shared/lib/bloom-filter/base-filter.js
./node_modules/.pnpm/next@13.4.2_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/shared/lib/bloom-filter/index.js
./node_modules/.pnpm/next@13.4.2_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/shared/lib/router/router.js
- wait compiling...
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: PoisonError { .. }', /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-compiler-3.2.1/src/engine/trap/frame_info.rs:220:39
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: PoisonError { .. }', /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-compiler-3.2.1/src/engine/trap/frame_info.rs:220:39
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: PoisonError { .. }', /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-compiler-3.2.1/src/engine/trap/frame_info.rs:220:39
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: PoisonError { .. }', /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-compiler-3.2.1/src/engine/trap/frame_info.rs:220:39
- error ./node_modules/.pnpm/next@13.4.2_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/shared/lib/router/router.js
Error: failed to process called `Result::unwrap()` on an `Err` value: PoisonError { .. }

Import trace for requested module:
./node_modules/.pnpm/next@13.4.2_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/shared/lib/router/router.js
fabio-nettis commented 1 year ago

@KorySchneider The idea is that when using Next.js it should be added into next.config.js otherwise the .swcrc file should be used, at least thats the way I've understood it. Maybe the documentation would also benefit from a slight change of wording.

ornakash commented 1 year ago

@fabio-nettis I tried to add

experimental: {
    swcPlugins: [
      ["@swc-jotai/debug-label", {}],
      ["@swc-jotai/react-refresh", {}],
    ],
  },

to next.config.js and I still get this error. Can you please elaborate on your solution with the .swcrc file?

fabio-nettis commented 1 year ago

@ornakash This configuration is completely valid according to the docs. But there seems to be a bug in the plugins rendering them unusable with the current next version. Henceforth the creation of this issue.

Thisen commented 1 year ago

This is a duplicate of #11.

Same issue as here: https://github.com/wasmerio/wasmer/issues/3793