cloudflare / cloudflare/workerd

panicked at 'already borrowed: BorrowMutError' in wasm-bindgen futures

Open
#442 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
8.7k
Forks
739
Avg merge
2d 20h
Merged PRs (30d)
174

Description

I'm running into an error where the workerd runtime is causing wasm-bindgen to panick.

https://github.com/rustwasm/wasm-bindgen/issues/2562#issuecomment-1374923064

it's a bug that i can consistently reproduce on a specific route when using the rust wasm workers
according to [the comment](https://github.com/rustwasm/wasm-bindgen/issues/2562#issuecomment-1379831230), apparently the cloudflare workerd runtime has different behaviour to the browsers runtime leading to the bug

the bug can also be ran into when serving a large amount of requests, aka load testing
i don't really know how to debug workerd to fix the issue, but it's a really annoying one that's stopping me from using workers in production

```
Error
at __wbg_new_abda76e883ba8a5f (shim.js:415:19)
at console_error_panic_hook::hook::h36ed105c675de4f7 (wasm://wasm/00f1df7a:wasm-function[1750]:0x181a6e)
at core::ops::function::Fn::call::h9f9f084f27f78c00 (wasm://wasm/00f1df7a:wasm-function[6876]:0x2046af)
at std::panicking::rust_panic_with_hook::had8acafc277b06ff (wasm://wasm/00f1df7a:wasm-function[2361]:0x1a7e35)
at std::panicking::begin_panic_handler::{{closure}}::h1f07988bb2cf1601 (wasm://wasm/00f1df7a:wasm-function[2952]:0x1c3341)
at std::sys_common::backtrace::__rust_end_short_backtrace::h9b10ea262b3bcf96 (wasm://wasm/00f1df7a:wasm-function[5362]:0x1fb990)
at rust_begin_unwind (wasm://wasm/00f1df7a:wasm-function[4162]:0x1e79aa)
at core::panicking::panic_fmt::h0498752af691fa0d (wasm://wasm/00f1df7a:wasm-function[4988]:0x1f6b8e)
at core::result::unwrap_failed::hff7d8a43159e0958 (wasm://wasm/00f1df7a:wasm-function[3151]:0x1cacfc)
at wasm_bindgen_futures::task::singlethread::Task::run::hdda06db3adb32b62 (wasm://wasm/00f1df7a:wasm-function[2200]:0x19f0be)
```

---

I have a reproduction of the panick, albeit not a simplified one.

```bash
git clone https://github.com/samdenty/github-icons
cd api
wrangler dev
```

- Once it prompts, turn on local mode by pressing `L`.
- Then in postman fetch the URL `http://127.0.0.1:8787/facebook/yoga` (if you navigate to it in chrome, it won't work as it'll try to redirect to homepage).
- Observe the error in the console

CleanShot 2023-03-10 at 17 20 02@2x

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.