Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wasm] ThreadPoolBuildError: operation not supported on this platform #5275

Closed
nolanlawson opened this issue Jul 22, 2022 · 1 comment · Fixed by #5353
Closed

[wasm] ThreadPoolBuildError: operation not supported on this platform #5275

nolanlawson opened this issue Jul 22, 2022 · 1 comment · Fixed by #5353
Labels
Milestone

Comments

@nolanlawson
Copy link

Describe the bug

Here is a minimal repro. The repro is using minifySync to minify the latest jquery.js:

const fs = require('fs')
const { minifySync } = require('@swc/wasm')

const src = fs.readFileSync('./jquery.js', 'utf8')

minifySync(src, {})

Input code

(See repro above)

Config

None

Playground link

No response

Expected behavior

No error, the code is minified.

Actual behavior

The code exits with error code 1 and this output:

panicked at 'The global thread pool has not been initialized.: ThreadPoolBuildError { kind: IOError(Error { kind: Unsupported, message: "operation not supported on this platform" }) }', /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.9.2/src/registry.rs:170:10

Stack:

Error
    at module.exports.__wbg_new_693216e109162396 (/Users/nlawson/workspace/repro-swc-wasm/node_modules/@swc/wasm/wasm.js:243:15)
    at console_error_panic_hook::hook::hb383505b44a300d4 (wasm://wasm/0514c836:wasm-function[4804]:0xd14ca1)
    at core::ops::function::Fn::call::ha056b037f91ead27 (wasm://wasm/0514c836:wasm-function[13634]:0xfdea81)
    at std::panicking::rust_panic_with_hook::h4cda35b38c02aa07 (wasm://wasm/0514c836:wasm-function[10826]:0xfa1b6f)
    at std::panicking::begin_panic_handler::{{closure}}::h49403edc6ccf77a1 (wasm://wasm/0514c836:wasm-function[11372]:0xfba332)
    at std::sys_common::backtrace::__rust_end_short_backtrace::heced27ce30abe76d (wasm://wasm/0514c836:wasm-function[13394]:0xfddd62)
    at rust_begin_unwind (wasm://wasm/0514c836:wasm-function[13026]:0xfdbb44)
    at core::panicking::panic_fmt::h9c0d7b6c636b07b0 (wasm://wasm/0514c836:wasm-function[12447]:0xfd6291)
    at core::result::unwrap_failed::h4573fd463ec3c95b (wasm://wasm/0514c836:wasm-function[11701]:0xfc582d)
    at rayon_core::registry::global_registry::hd1f64ffc964182d0 (wasm://wasm/0514c836:wasm-function[10555]:0xf93389)


wasm://wasm/0514c836:1


RuntimeError: unreachable
    at rust_panic (wasm://wasm/0514c836:wasm-function[13679]:0xfdec11)
    at std::panicking::rust_panic_with_hook::h4cda35b38c02aa07 (wasm://wasm/0514c836:wasm-function[10826]:0xfa1b98)
    at std::panicking::begin_panic_handler::{{closure}}::h49403edc6ccf77a1 (wasm://wasm/0514c836:wasm-function[11372]:0xfba332)
    at std::sys_common::backtrace::__rust_end_short_backtrace::heced27ce30abe76d (wasm://wasm/0514c836:wasm-function[13394]:0xfddd62)
    at rust_begin_unwind (wasm://wasm/0514c836:wasm-function[13026]:0xfdbb44)
    at core::panicking::panic_fmt::h9c0d7b6c636b07b0 (wasm://wasm/0514c836:wasm-function[12447]:0xfd6291)
    at core::result::unwrap_failed::h4573fd463ec3c95b (wasm://wasm/0514c836:wasm-function[11701]:0xfc582d)
    at rayon_core::registry::global_registry::hd1f64ffc964182d0 (wasm://wasm/0514c836:wasm-function[10555]:0xf93389)
    at <swc_ecma_minifier::pass::precompress::PrecompressOptimizer as swc_ecma_visit::VisitMut>::visit_mut_stmts::he60f1380c98d37bd (wasm://wasm/0514c836:wasm-function[1260]:0x884b33)
    at swc_ecma_visit::visit_mut_function::h2d83ee43fa47519d (wasm://wasm/0514c836:wasm-function[7846]:0xeba46f)

Node.js v18.6.0

Version

1.2.218

Additional context

Apparently (image-rs/image#1496 (comment)) the error is caused by the rayon Rust crate.

Also my environment (macOS, Intel, 2020 13-inch MacBook Pro) may be relevant here:

$ sw_vers
ProductName:    macOS
ProductVersion: 11.6.7
BuildVersion:   20G630
$ node
Welcome to Node.js v18.6.0.
> process.platform
'darwin'
> os.arch()
'x64'
> os.endianness()
'LE'
@swc-bot
Copy link
Collaborator

swc-bot commented Oct 16, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Oct 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

3 participants