swc-jotai
swc-jotai copied to clipboard
Broke on @swc/[email protected]: called `Result::unwrap()` on an `Err` value: LayoutError
Hi, it’s great to learn and practice this project.
After I updated @swc/core in my vite-based project to version 1.3.106, when running vite dev, I got the following error message in the console:
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: LayoutError', /Users/thisen/.cargo/registry/src/github.com-1ecc6299db9ec823/rkyv-0.7.42/src/impls/core/mod.rs:266:67
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread '<unnamed>' panicked at /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc-0.272.1/src/plugin.rs:162:14:
failed to invoke plugin: failed to invoke plugin on 'Some("<project_path>/webapp/index.tsx")'
Caused by:
0: failed to invoke `<project_path>/node_modules/@swc-jotai/debug-label/swc_jotai_debug_label.wasm` as js transform plugin at <project_path>/node_modules/@swc-jotai/debug-label/swc_jotai_debug_label.wasm
1: RuntimeError: unreachable
More with `RUST_BACKTRACE=1`
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: LayoutError', /Users/thisen/.cargo/registry/src/github.com-1ecc6299db9ec823/rkyv-0.7.42/src/impls/core/mod.rs:266:67
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread '<unnamed>' panicked at /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc-0.272.1/src/plugin.rs:162:14:
failed to invoke plugin: failed to invoke plugin on 'Some("<project_path>/webapp/index.tsx")'
Caused by:
0: failed to invoke `<project_path>/node_modules/@swc-jotai/debug-label/swc_jotai_debug_label.wasm` as js transform plugin at <project_path>/node_modules/@swc-jotai/debug-label/swc_jotai_debug_label.wasm
1: RuntimeError: unreachable
Stack backtrace:
0: _napi_register_module_v1
1: _wasmer_vm_imported_memory32_atomic_notify
2: _napi_register_module_v1
3: _napi_register_module_v1
4: _napi_register_module_v1
5: _napi_register_module_v1
6: _napi_register_module_v1
7: _napi_register_module_v1
8: _napi_register_module_v1
9: <unknown>
10: __ZZN4node14ThreadPoolWork12ScheduleWorkEvENKUlP9uv_work_sE_clES2_
11: __ZZN4node14ThreadPoolWork12ScheduleWorkEvENUlP9uv_work_sE_8__invokeES2_
12: _worker
13: __pthread_joiner_wake
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
1:18:33 PM [vite] Internal server error: failed to handle: failed to invoke plugin: failed to invoke plugin on 'Some("<project_path>/webapp/index.tsx")'
Caused by:
0: failed to invoke `<project_path>/node_modules/@swc-jotai/debug-label/swc_jotai_debug_label.wasm` as js transform plugin at <project_path>/node_modules/@swc-jotai/debug-label/swc_jotai_debug_label.wasm
1: RuntimeError: unreachable
Stack backtrace:
0: _napi_register_module_v1
1: _wasmer_vm_imported_memory32_atomic_notify
2: _napi_register_module_v1
3: _napi_register_module_v1
4: _napi_register_module_v1
5: _napi_register_module_v1
6: _napi_register_module_v1
7: _napi_register_module_v1
8: _napi_register_module_v1
9: <unknown>
10: __ZZN4node14ThreadPoolWork12ScheduleWorkEvENKUlP9uv_work_sE_clES2_
11: __ZZN4node14ThreadPoolWork12ScheduleWorkEvENUlP9uv_work_sE_8__invokeES2_
12: _worker
13: __pthread_joiner_wake
Stack backtrace:
0: _napi_register_module_v1
1: _wasmer_vm_imported_memory32_atomic_notify
2: <unknown>
3: __ZZN4node14ThreadPoolWork12ScheduleWorkEvENKUlP9uv_work_sE_clES2_
4: __ZZN4node14ThreadPoolWork12ScheduleWorkEvENUlP9uv_work_sE_8__invokeES2_
5: _worker
6: __pthread_joiner_wake
Plugin: vite:react-swc
File: <project_path>/webapp/index.tsx
1:18:33 PM [vite] Pre-transform error: failed to handle: failed to invoke plugin: failed to invoke plugin on 'Some("<project_path>/webapp/index.tsx")'
Caused by:
0: failed to invoke `<project_path>/node_modules/@swc-jotai/debug-label/swc_jotai_debug_label.wasm` as js transform plugin at <project_path>/node_modules/@swc-jotai/debug-label/swc_jotai_debug_label.wasm
1: RuntimeError: unreachable
Stack backtrace:
0: _napi_register_module_v1
1: _wasmer_vm_imported_memory32_atomic_notify
2: _napi_register_module_v1
3: _napi_register_module_v1
4: _napi_register_module_v1
5: _napi_register_module_v1
6: _napi_register_module_v1
7: _napi_register_module_v1
8: _napi_register_module_v1
9: <unknown>
10: __ZZN4node14ThreadPoolWork12ScheduleWorkEvENKUlP9uv_work_sE_clES2_
11: __ZZN4node14ThreadPoolWork12ScheduleWorkEvENUlP9uv_work_sE_8__invokeES2_
12: _worker
13: __pthread_joiner_wake
Stack backtrace:
0: _napi_register_module_v1
1: _wasmer_vm_imported_memory32_atomic_notify
2: <unknown>
3: __ZZN4node14ThreadPoolWork12ScheduleWorkEvENKUlP9uv_work_sE_clES2_
4: __ZZN4node14ThreadPoolWork12ScheduleWorkEvENUlP9uv_work_sE_8__invokeES2_
5: _worker
6: __pthread_joiner_wake
It works fine on @swc/[email protected].
Any incompatibilities there?
Thanks.
I updated @swc/core
to the latest version 1.3.107, and the problem still exists.
Reproducing here
Confirmed this doesn't happen with version 1.3.105
It started happening in 1.3.106 and confirmed also in 1.3.107
I am now getting this error in Next.js after updating to 14.2.0. It seems like Next.js got updated to this version of SWC and the plugin is unusable with Next.js now.
Hi there!
Thanks for reporting.
Can you provide a reproduction with latest releases of packages?
Hi there!
Thanks for reporting.
Can you provide a reproduction with latest releases of packages?
Verified that it works fine when using @swc-jotai/[email protected]
and @swc/[email protected]
(both are the latest versions).
Perfect fix, thanks.
I don't know where I am supposed to file this issue. I am still receiving the error above with a fresh vite install.
@swc-jotai/[email protected] @swc/[email protected]
npm explain @swc/core
# @swc/[email protected] dev
# node_modules/@swc/core
# @swc/core@"^1.5.7" from @vitejs/[email protected]
# node_modules/@vitejs/plugin-react-swc
# dev @vitejs/plugin-react-swc@"^3.5.0" from the root project
npm create vite@latest jotai-debug-label -- --template react-swc-ts && \
cd jotai-debug-label && npm install && npm install --save-dev @swc-jotai/debug-label
// vite.config.ts
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react({ plugins: [["@swc-jotai/debug-label", {}]] })]
})
{
"name": "jotai-debug-label",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"jotai": "^2.9.3",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@eslint/js": "^9.9.0",
"@swc-jotai/debug-label": "^0.1.1",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react-swc": "^3.5.0",
"eslint": "^9.9.0",
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
"eslint-plugin-react-refresh": "^0.4.9",
"globals": "^15.9.0",
"typescript": "^5.5.3",
"typescript-eslint": "^8.0.1",
"vite": "^5.4.1"
}
}
The error message.
thread '<unnamed>' panicked at /Users/thisen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rkyv-0.7.44/src/impls/core/mod.rs:266:67:
called `Result::unwrap()` on an `Err` value: LayoutError
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread '<unnamed>' panicked at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/swc-0.285.0/src/plugin.rs:169:14:
failed to invoke plugin: failed to invoke plugin on 'Some("/home/tom/code/test/jotai-debug-label/src/main.tsx")'
I am now getting this error in Next.js after updating to 14.2.0. It seems like Next.js got updated to this version of SWC and the plugin is unusable with Next.js now.
If it can help someone:
I upgraded too Next.js to v14.2
and it made incompatible next-superjson-plugin
. I tried to override package versions of SWC but it didn't work, so I directly updated this package to v0.6
that is using ESM only (which may be not ideal for some setups).