OOM with emotion plugin?

I was looking at adopting swc with the emotion plugin in one of our repositories when I hit this:
Caused by:
0: failed to invoke `@swc/plugin-emotion` as js transform plugin at ../../node_modules/@swc/plugin-emotion/swc_plugin_emotion.wasm
1: RuntimeError: out of bounds memory access
2: heap_get_oob', /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc-0.260.1/src/plugin.rs:228:14
failed to handle: failed to invoke plugin: failed to invoke plugin on 'Some("src/components/x.tsx")'
Caused by:
0: failed to invoke `@swc/plugin-emotion` as js transform plugin at ../../node_modules/@swc/plugin-emotion/swc_plugin_emotion.wasm
1: RuntimeError: out of bounds memory access
2: heap_get_oob', /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc-0.260.1/src/plugin.rs:228:14
failed to handle: failed to invoke plugin: failed to invoke plugin on 'Some("src/components/x.tsx")'
21 Replies
Codex
CodexOP•3y ago
With full backtrace:
Caused by:
0: failed to invoke `@swc/plugin-emotion` as js transform plugin at ../../node_modules/@swc/plugin-emotion/swc_plugin_emotion.wasm
1: RuntimeError: out of bounds memory access
2: heap_get_oob

Stack backtrace:
0: _napi_register_module_v1
1: _wasmer_vm_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: <unknown>
8: _worker
9: __pthread_joiner_wake', /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc-0.260.1/src/plugin.rs:228:14
stack backtrace:
0: 0x1182e13cc - _napi_register_module_v1
1: 0x117fff5dc - _blake3_compress_in_place_portable
2: 0x1182bef18 - _napi_register_module_v1
3: 0x1182e2450 - _napi_register_module_v1
4: 0x1182e20b0 - _napi_register_module_v1
5: 0x1182e2f80 - _napi_register_module_v1
6: 0x1182e2afc - _napi_register_module_v1
7: 0x1182e2a6c - _napi_register_module_v1
8: 0x1182e2a60 - _napi_register_module_v1
9: 0x11958c884 - _wasmer_vm_memory32_atomic_notify
10: 0x11958cad8 - _wasmer_vm_memory32_atomic_notify
11: 0x118408250 - _napi_register_module_v1
12: 0x1183b5564 - _napi_register_module_v1
13: 0x1183b3fb0 - _napi_register_module_v1
14: 0x117df1748 - <unknown>
15: 0x103223db0 - _worker
16: 0x18835ffa8 - __pthread_joiner_wake
failed to handle: failed to invoke plugin: failed to invoke plugin on 'Some("src/helper/x.tsx")'
Caused by:
0: failed to invoke `@swc/plugin-emotion` as js transform plugin at ../../node_modules/@swc/plugin-emotion/swc_plugin_emotion.wasm
1: RuntimeError: out of bounds memory access
2: heap_get_oob

Stack backtrace:
0: _napi_register_module_v1
1: _wasmer_vm_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: <unknown>
8: _worker
9: __pthread_joiner_wake', /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc-0.260.1/src/plugin.rs:228:14
stack backtrace:
0: 0x1182e13cc - _napi_register_module_v1
1: 0x117fff5dc - _blake3_compress_in_place_portable
2: 0x1182bef18 - _napi_register_module_v1
3: 0x1182e2450 - _napi_register_module_v1
4: 0x1182e20b0 - _napi_register_module_v1
5: 0x1182e2f80 - _napi_register_module_v1
6: 0x1182e2afc - _napi_register_module_v1
7: 0x1182e2a6c - _napi_register_module_v1
8: 0x1182e2a60 - _napi_register_module_v1
9: 0x11958c884 - _wasmer_vm_memory32_atomic_notify
10: 0x11958cad8 - _wasmer_vm_memory32_atomic_notify
11: 0x118408250 - _napi_register_module_v1
12: 0x1183b5564 - _napi_register_module_v1
13: 0x1183b3fb0 - _napi_register_module_v1
14: 0x117df1748 - <unknown>
15: 0x103223db0 - _worker
16: 0x18835ffa8 - __pthread_joiner_wake
failed to handle: failed to invoke plugin: failed to invoke plugin on 'Some("src/helper/x.tsx")'
SWC config:
{
"exclude": [".*\\.(stories|spec|test)\\.tsx?$", "tests"],
"jsc": {
"parser": {
"syntax": "typescript",
"tsx": true
},
"target": "esnext",
"transform": {
"react": {
"runtime": "automatic"
}
},
"experimental": {
"plugins": [
[
"@swc/plugin-emotion",
{

}
]
]
}
},
"env": {
"targets": [">0.2%", "not dead", "not ie <=11", "not op_mini all"]
}
}
{
"exclude": [".*\\.(stories|spec|test)\\.tsx?$", "tests"],
"jsc": {
"parser": {
"syntax": "typescript",
"tsx": true
},
"target": "esnext",
"transform": {
"react": {
"runtime": "automatic"
}
},
"experimental": {
"plugins": [
[
"@swc/plugin-emotion",
{

}
]
]
}
},
"env": {
"targets": [">0.2%", "not dead", "not ie <=11", "not op_mini all"]
}
}
The compilation works if we remove the plugin Compilation also works if I target each folder individually in the sources Unsure where to go from here for trying to find the cause 🤔
kdy1
kdy1•3y ago
I think you should remove all .swc
Codex
CodexOP•3y ago
The temp .swc folders?
kdy1
kdy1•3y ago
Yeap
Codex
CodexOP•3y ago
Ah, I have already, I have, completely removed them with rm -rf **/.swc, removed all node modules, wiped to a clean state, installed from npm again, and tried again. Same problem :pensive_cowboy:
kdy1
kdy1•3y ago
Selecting the version – SWC
SWC is an extensible Rust-based platform for the next generation of fast developer tools. It's used by tools like Next.js, Parcel, and Deno, as well as companies like Vercel, ByteDance, Tencent, Shopify, and more.
Codex
CodexOP•3y ago
Not sure what you're asking me to do here, I'm using: - @swc/cli 0.1.62 - @swc/core 1.3.49 - @swc/plugin-emotion 2.5.59 @swc/core-* packages are all also at 1.3.49 in the lock Also, the plugin works for each file and folder independently, but crashes with OOM when doing the project (which is a small project as well, really small) Just tried: - completely removing all @swc packages - Ensuring there are none remaining in the package lock - deleting all node_modules - deleting all .swc - npm i -D @swc/cli @swc/core @swc/plugin-emotion Sadly, it still explodes
kdy1
kdy1•3y ago
Then please file an issue
Unknown User
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Codex
CodexOP•3y ago
I was able to recreate the issue easily with the mui repo lol I'll file an issue
kdy1
kdy1•3y ago
Does it still happen with the latest version of @swc/core?
Codex
CodexOP•3y ago
yes I did a fresh clone of the mui repo and freshly added the swc cli, core, plugin
kdy1
kdy1•3y ago
Ah
Codex
CodexOP•3y ago
then created a basic .swcrc with the plugin, and attempted to compile the mui-material package
kdy1
kdy1•3y ago
Are you using M1 mac or arm processor?
Codex
CodexOP•3y ago
yes M1 mac
kdy1
kdy1•3y ago
GitHub
Plugin fails on arm processor · Issue #7255 · swc-project/swc
Versions: "@swc/plugin-styled-components": "1.5.59", "@swc/core": "1.3.49" Error: Caused by: 0: failed to invoke `/Users/difuks/WebstormProjects/kiosk/src/fr...
Codex
CodexOP•3y ago
well, damn lol :sad: Most of my team are on M1 macs, tragic
kdy1
kdy1•3y ago
Same here I'm using m1 mac But well we need a repro anyway Can you create a repro and left a comment on the issue? I can try updating wasmer or transitive deps (e.g. cranelift-codegen)
Codex
CodexOP•3y ago
GitHub
[@swc/plugin-emotion] out of bounds memory access · Issue #176 · sw...
This is probably related to swc-project/swc#7255 Caused by: 0: failed to invoke @swc/plugin-emotion as js transform plugin at ../../node_modules/@swc/plugin-emotion/swc_plugin_emotion.wasm 1: Run...
Codex
CodexOP•3y ago
Added a comment too

Did you find this page helpful?