Closed fpapado closed 2 weeks ago
I think there's a UB in the code related to rkyv
. When I run it via cargo test
, it works.
If I add logging code and run it via node.js, it hangs.
If I run it without logging code, it crashes with the error message in the issue body.
@kwonoj What do you think? Should we update rkyv
(and wasmer) first?
Do we have exact change caused this regression? If we revert those what we'll lose?
I'm in for rkyv / wasmer update and it should happen, but rkyv had major breaking so update would require some code changes - also we are't 100% sure if update will fix this issue.
The problematic patch is https://github.com/swc-project/swc/pull/9696, which makes source file analysis of swc_common
lazy, improving the total runtime by 2% ~ 5%.
I introduced CacheCellrkyv-impl
at https://github.com/swc-project/swc/blob/499c8034133417dd01e864c1e11844f6ce9215dc/crates/swc_common/src/cache.rs#L35-L115 is problematic, but I failed to debug.
Isn't rspack attempt to upgrade to latest swc in the next release? Blocking all plugin sounds like a deal breaker; maybe cost those perf improvement and revert, then retry after rkyv / wasmer update?
It's not all Wasm plugin, but I think we should revert it anyway. I left a question on rkyv Discord, so if it's a real UB, I'll revert the PR and reapply it after updating rkyv
I triggered the publish pipeline for @swc/core@v1.9.0
Using @swc/core@v1.9.1
and various plugins, e.g. @swc/plugin-styled-components@v5.0.0
has now resolved the issue mentioned above for our environment.
Can confirm that this works for us as well. Thank you for the quick fix 🎉
Describe the bug
Follow the reproduction at https://github.com/fpapado/swc-1.8.0-and-plugin-styled-components-4.0.0.
Using @swc/core@1.8.0 together with @swc/plugin-styled-components@4.0.0 and then attempting to transpile a file leads to a panic. This seems contrary to https://plugins.swc.rs/versions/range/19, which shows @swc/core@1.8.0 and @swc/plugin-styled-components@4.0.0 as compatible.
Input code
Config
Playground link (or link to the minimal reproduction)
https://github.com/fpapado/swc-1.8.0-and-plugin-styled-components-4.0.0
SWC Info output
/Users/fotis/Library/Application Support/fnm/node-versions/v20.18.0/installation/lib/node_modules/corepack/dist/lib/corepack.cjs:22373 throw new UsageError(
This project is configured to use ${result.spec.name} because ${result.target} has a "packageManager" field
); ^UsageError: This project is configured to use pnpm because /Users/fotis/swc-1.8.0-and-plugin-styled-components-4.0.0/package.json has a "packageManager" field at Engine.findProjectSpec (/Users/fotis/Library/Application Support/fnm/node-versions/v20.18.0/installation/lib/node_modules/corepack/dist/lib/corepack.cjs:22373:21) at async Engine.executePackageManagerRequest (/Users/fotis/Library/Application Support/fnm/node-versions/v20.18.0/installation/lib/node_modules/corepack/dist/lib/corepack.cjs:22404:24) at async Object.runMain (/Users/fotis/Library/Application Support/fnm/node-versions/v20.18.0/installation/lib/node_modules/corepack/dist/lib/corepack.cjs:23096:5) { clipanion: { type: 'usage' } }
Node.js v20.18.0
Expected behavior
I expected swc to transpile the code without errors around the plugin's compatibility with core, as listed in https://plugins.swc.rs/versions/range/19.
Actual behavior
SWC exits with a panic
Version
1.8.0
Additional context
Please let me know if there is any other information that I can provide, and I will get back to you promptly 😌