pmndrs / swc-jotai

MIT License
90 stars 14 forks source link

Broke on @swc/core@1.3.106: called `Result::unwrap()` on an `Err` value: LayoutError #22

Closed Tiscs closed 2 months ago

Tiscs commented 7 months ago

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` ``` sh thread '' 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 '' 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("/webapp/index.tsx")' Caused by: 0: failed to invoke `/node_modules/@swc-jotai/debug-label/swc_jotai_debug_label.wasm` as js transform plugin at /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: 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("/webapp/index.tsx")' Caused by: 0: failed to invoke `/node_modules/@swc-jotai/debug-label/swc_jotai_debug_label.wasm` as js transform plugin at /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: 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: 3: __ZZN4node14ThreadPoolWork12ScheduleWorkEvENKUlP9uv_work_sE_clES2_ 4: __ZZN4node14ThreadPoolWork12ScheduleWorkEvENUlP9uv_work_sE_8__invokeES2_ 5: _worker 6: __pthread_joiner_wake Plugin: vite:react-swc File: /webapp/index.tsx 1:18:33 PM [vite] Pre-transform error: failed to handle: failed to invoke plugin: failed to invoke plugin on 'Some("/webapp/index.tsx")' Caused by: 0: failed to invoke `/node_modules/@swc-jotai/debug-label/swc_jotai_debug_label.wasm` as js transform plugin at /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: 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: 3: __ZZN4node14ThreadPoolWork12ScheduleWorkEvENKUlP9uv_work_sE_clES2_ 4: __ZZN4node14ThreadPoolWork12ScheduleWorkEvENUlP9uv_work_sE_8__invokeES2_ 5: _worker 6: __pthread_joiner_wake ```

It works fine on @swc/core@1.3.105.

Any incompatibilities there?

Thanks.

Tiscs commented 7 months ago

I updated @swc/core to the latest version 1.3.107, and the problem still exists.

gunta commented 7 months ago

Reproducing here

gunta commented 7 months ago

Confirmed this doesn't happen with version 1.3.105

It started happening in 1.3.106 and confirmed also in 1.3.107

nizioleque commented 4 months ago

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.

Thisen commented 2 months ago

Hi there!

Thanks for reporting.

Can you provide a reproduction with latest releases of packages?

Tiscs commented 2 months ago

Hi there!

Thanks for reporting.

Can you provide a reproduction with latest releases of packages?

Verified that it works fine when using @swc-jotai/debug-label@0.1.1 and @swc/core@1.5.29 (both are the latest versions). Perfect fix, thanks.

tomschulze commented 1 week ago

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/debug-label@0.1.1 @swc/core@1.7.19

npm explain @swc/core
# @swc/core@1.7.19 dev
# node_modules/@swc/core
#  @swc/core@"^1.5.7" from @vitejs/plugin-react-swc@3.7.0
#   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")'