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

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

Closed
romanusname opened this issue May 8, 2023 · 5 comments
Labels

Comments

@romanusname
Copy link

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

@romanusname romanusname added the bug label May 8, 2023
@snOm3ad
Copy link
Contributor

snOm3ad commented May 8, 2023

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
Copy link
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
Copy link
Collaborator

daxpedda commented May 9, 2023

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
Copy link
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
Copy link
Collaborator

daxpedda commented May 12, 2023

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.

@daxpedda daxpedda closed this as not planned Won't fix, can't repro, duplicate, stale May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants