kwonoj/swc-plugin-coverage-instrument

BUG: failed to invoke swc_plugin_coverage.wasm

Closed this issue · 2 comments

Attempted to load the plugin into NextJS but this got a rust panic. I have a feeling it might be NextJS with all their recent changes but thought it wise to start here. Thanks for time.

You can find a minimal reproduction on codesandbox.
https://codesandbox.io/p/sandbox/blue-architecture-fg98t9

thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: LayoutError', /Users/ojkwon/.cargo/registry/src/index.crates.io-6f17d22bba15001f/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 'failed to invoke plugin: failed to invoke plugin on 'Some("/project/sandbox/app/page.tsx")'

Caused by:
    0: failed to invoke `/project/sandbox/node_modules/swc-plugin-coverage-instrument/target/wasm32-wasi/release/swc_plugin_coverage.wasm` as js transform plugin at /project/sandbox/node_modules/swc-plugin-coverage-instrument/target/wasm32-wasi/release/swc_plugin_coverage.wasm
    1: RuntimeError: unreachable
           at __rust_start_panic (<module>[3836]:0x2c601c)
           at rust_panic (<module>[3824]:0x2c5d09)
           at std::panicking::rust_panic_with_hook::hda1480d1de059bbb (<module>[3823]:0x2c5ce4)
           at std::panicking::begin_panic_handler::{{closure}}::ha778096dbcb1900b (<module>[3811]:0x2c504a)
           at std::sys_common::backtrace::__rust_end_short_backtrace::h40fc583fcea7890a (<module>[3810]:0x2c4f77)
           at rust_begin_unwind (<module>[3818]:0x2c55fa)
           at core::panicking::panic_fmt::h1bc5950702b1fd20 (<module>[3975]:0x2d3b47)
           at core::result::unwrap_failed::h029a3e98dab0ed57 (<module>[4020]:0x2dac78)
           at rkyv::impls::core::option::<impl rkyv::Deserialize<core::option::Option<T>,D> for rkyv::option::ArchivedOption<<T as rkyv::Archive>::Archived>>::deserialize::h45ca34ffc4fc323c (<module>[2995]:0x2695b5)
           at swc_common::plugin::serialized::PluginSerializedBytes::deserialize::h0ae8e0a332756567 (<module>[2994]:0x268ca6)
           at swc_plugin_proxy::memory_interop::read_returned_result_from_host::read_returned_result_from_host::h6a0774cdb20ecc39 (<module>[3011]:0x26b701)
           at <swc_plugin_proxy::source_map::plugin_source_map_proxy::PluginSourceMapProxy as swc_common::errors::SourceMapper>::lookup_char_pos::h643472b47c2658fb (<module>[3020]:0x26cc15)
           at swc_coverage_instrument::utils::lookup_range::get_range_from_span::hf09ac37fa7d1a212 (<module>[894]:0x13ec59)
           at swc_coverage_instrument::visitors::coverage_visitor::CoverageVisitor<C,S>::create_fn_instrumentation::h8c20f0d7cdf2ef0d (<module>[1281]:0x174f52)
           at <swc_coverage_instrument::visitors::coverage_visitor::CoverageVisitor<C,S> as swc_ecma_visit::VisitMut>::visit_mut_fn_expr::h9dd0adde464f8263 (<module>[1282]:0x17578a)
           at <swc_coverage_instrument::visitors::coverage_visitor::CoverageVisitor<C,S> as swc_ecma_visit::VisitMut>::visit_mut_export_default_decl::h9f0ff7ca332b375c (<module>[1328]:0x185a0f)
           at swc_ecma_visit::visit_mut_module_decl::h236155c3355602fc (<module>[1530]:0x1a3af9)
           at <swc_coverage_instrument::visitors::coverage_visitor::CoverageVisitor<C,S> as swc_ecma_visit::VisitMut>::visit_mut_module_items::hfa605baa556b6c49 (<module>[1322]:0x183e4c)
           at __transform_plugin_process_impl (<module>[1383]:0x18cf24)
           at __transform_plugin_process_impl.command_export (<module>[4144]:0x2e2631)
    2: unreachable', /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.245.25/src/plugin.rs:228:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

kwonoj commented

Not sure if sharing link is correct, any case this no longer repro with latest pkg + latest next.js.