Skip to content

Error while importing "__wbindgen_placeholder__"."__wbindgen_describe": unknown import. Expected Function(FunctionType { params: [I32], results: [] }) #3413

@romanusname

Description

@romanusname

Describe the Bug

I am creating a SWC plugin for next js.
I recently started getting an error when running the plugin.

Now this error does not go away. Any recompiled plugin breaks the application. The same plugin compiled a few days ago works.

I reinstalled: cargo, rust, swc_core.

The error text brought me here. What does this error mean? Please help me understand.

In SWC they told me - check if all versions are latest. YES, but that's where their help ended.

Steps to Reproduce

I am completely following the instructions:
https://swc.rs/docs/plugin/ecmascript/getting-started
Run next js and I get an error.

The same plugin that I compiled a few days ago works in the latest version of Next js.
But everything I compile now breaks the application

Expected Behavior

The application must not break

Actual Behavior

thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("C:\\Users\\79833\\WebstormProjects\\TestSWC\\nextnew\\node_modules\\next
\\dist\\client\\dev\\amp-dev.js")'

Caused by:
    Error while importing "__wbindgen_placeholder__"."__wbindgen_describe": unknown import. Expected Function(FunctionType { params: [I32], results: [] })', C:\Use
rs\runneradmin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\swc-0.260.41\src\plugin.rs:219:14
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("C:\\Users\\79833\\WebstormProjects\\TestSWC\\nextnew\\node_modules\\next
\\dist\\client\\next-dev.js")'

Caused by:
    Error while importing "__wbindgen_placeholder__"."__wbindgen_describe": unknown import. Expected Function(FunctionType { params: [I32], results: [] })', C:\Use
rs\runneradmin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\swc-0.260.41\src\plugin.rs:219:14
thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("C:\\Users\\79833\\WebstormProjects\\TestSWC\\nextnew\\node_modules\\next
\\dist\\client\\router.js")'

Caused by:
    Error while importing "__wbindgen_placeholder__"."__wbindgen_describe": unknown import. Expected Function(FunctionType { params: [I32], results: [] })', C:\Use
rs\runneradmin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\swc-0.260.41\src\plugin.rs:219:14
thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("C:\\Users\\79833\\WebstormProjects\\TestSWC\\nextnew\\node_modules\\next
\\dist\\client\\app-next-dev.js")'

Caused by:
    Error while importing "__wbindgen_placeholder__"."__wbindgen_describe": unknown import. Expected Function(FunctionType { params: [I32], results: [] })', C:\Use
rs\runneradmin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\swc-0.260.41\src\plugin.rs:219:14
thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("C:\\Users\\79833\\WebstormProjects\\TestSWC\\nextnew\\node_modules\\next
\\dist\\pages\\_app.js")'

Additional Context

I don't add anything other than the SWC starter kit. This is definitely not my fault.

I reinstalled everything except windows. I am ready to test any theory to solve the problem, and provide any information. Answer, please. I need any advice

Activity

snOm3ad

snOm3ad commented on May 8, 2023

@snOm3ad
Contributor

SWC uses tracing for logging. By default, SWC testing library configures the log level to debug by default, and this can be controlled by using an environment variable named RUST_LOG.

Could you try setting RUST_LOG=trace and see if there's anything else in the logs?

romanusname

romanusname commented on May 9, 2023

@romanusname
Author

SWC uses tracing for logging. By default, SWC testing library configures the log level to debug by default, and this can be controlled by using an environment variable named RUST_LOG.

Could you try setting RUST_LOG=trace and see if there's anything else in the logs?
i setting - RUST_BACKTRACE=1, RUST_LOG=trace, SWC_DEBUG=1

Panic: PanicInfo { payload: Any { .. }, message: Some(failed to invoke plugin: failed to invoke plugin on 'Some("C:\\Users\\79833\\WebstormProjects\\TestSWC\\nextn
ew\\node_modules\\next\\dist\\client\\app-next-dev.js")'

Caused by:
    Error while importing "__wbindgen_placeholder__"."__wbindgen_describe": unknown import. Expected Function(FunctionType { params: [I32], results: [] })

Stack backtrace:
   0: napi_register_module_v1
   1: napi_register_module_v1
   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: BrotliDecoderVersion
   8: BrotliDecoderVersion
   9: canonical_abi_free
  10: canonical_abi_free
  11: canonical_abi_free
  12: canonical_abi_free
  13: canonical_abi_free
  14: canonical_abi_free
  15: canonical_abi_free
  16: v8::base::TimeDelta::TimeDelta
  17: uv_queue_work
  18: uv_poll_stop
  19: inflateValidate
  20: BaseThreadInitThunk
  21: RtlUserThreadStart), location: Location { file: "C:\\Users\\runneradmin\\.cargo\\registry\\src\\index.crates.io-6f17d22bba15001f\\swc-0.260.41\\src\\plugin.r
s", line: 219, col: 14 }, can_unwind: true }
Backtrace:    0: napi_register_module_v1
   1: napi_register_module_v1
   2: canonical_abi_free
   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: BrotliDecoderVersion
  10: canonical_abi_free
  11: canonical_abi_free
  12: canonical_abi_free
  13: canonical_abi_free
  14: canonical_abi_free
  15: canonical_abi_free
  16: canonical_abi_free
  17: v8::base::TimeDelta::TimeDelta
  18: uv_queue_work
  19: uv_poll_stop
  20: inflateValidate
  21: BaseThreadInitThunk
  22: RtlUserThreadStart

This error is printed to the console many times

daxpedda

daxpedda commented on May 9, 2023

@daxpedda
Contributor

I'm not sure this is the place to ask this, probably better to figure it out in SWC, if it is a bug in wasm-bindgen a more minimal example, that doesn't involve tools outside wasm-bindgen, would be really helpful.

romanusname

romanusname commented on May 9, 2023

@romanusname
Author

I'm not sure this is the place to ask this, probably better to figure it out in SWC, if it is a bug in wasm-bindgen a more minimal example, that doesn't involve tools outside wasm-bindgen, would be really helpful.

I asked this question to the SWC developers. Unfortunately they don't answer.

Why is this problem possible? I found a discussion thread with the same problem. In that case, another version of rust nightly helped. swc-project/swc#6883

I have tried this version and many others. And I will try all versions of rust. I have no other ideas :(

daxpedda

daxpedda commented on May 12, 2023

@daxpedda
Contributor

Looking at swc-project/swc#6883, the problem seems more clear now. The latest release seems to have broken WASI support, which is not actually officially supported by wasm-bindgen.

I encourage you to bring your use-case and point of view to #3421.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @daxpedda@snOm3ad@romanusname

        Issue actions

          Error while importing "__wbindgen_placeholder__"."__wbindgen_describe": unknown import. Expected Function(FunctionType { params: [I32], results: [] }) · Issue #3413 · wasm-bindgen/wasm-bindgen