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

Add __wbindgen_throw to importObject #1

wants to merge 1 commit into from

Add __wbindgen_throw to importObject #1

wants to merge 1 commit into from


Copy link

I was following your serverless-rust tutorial on my own.

I was getting an error in the CloudFlare Script editor on save, that the function __wbindgen_throw was missing :

Uncaught LinkError: WebAssembly Instantiation: Import #2 module="./serverless_rust" function="__wbindgen_throw" error: function import requires a callable at line 79 in mod at line 87


wasm-objdump pkg/serverless_rust_bg.wasm -x

it seems my WASM is importing "__wbindgen_throw":

....deleted lines....
 - name: "name"
 - func[0] <__wbg_alert_a6f756c1262c4809>
 - func[1] <__wbg_now_7e59c3475b182c97>
 - func[2] <__wbindgen_throw>
....deleted lines....

and I saw it was implemented in the generated JS:

 function __wbindgen_throw(ptr, len) {
      throw new Error(getStringFromWasm(ptr, len));

so I added it to the importObject:

  const importObject = {
    './serverless_rust': {

(those are my function references, won't coincide with your code)....

and everything worked!

This maybe caused by some update to the wasm-bindgen or wasm-pack since you wrote the tutorial maybe?

When following the tutorial on my own, it seems my WASM is importing "__wbindgen_throw", and I saw it implemented in the JS, and I was getting an error on it being missing in the CloudFlare Script editor, so I added it to the importObject and everything worked.
Copy link

Thanks Andrew! I don't have the environment setup anymore to try this out but I've updated the blog post with a link to your PR and a credit to help folks find their way.

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

Successfully merging this pull request may close these issues.

None yet

2 participants