Ideas on tracking down "Module imports function '__wbindgen_describe' from '__wbindgen_placeholder__' that is not exported by the runtime."

I’m trying to import a large crate that supports wasm32-u-u, but most likely uses things that are not supported by the IC runtime. In the past the main culprits were time() stuff and rand() stuff. As the crate I’m looking at is pretty large, there are a lot of dependencies and I’d like to know if there’s a way to narrow down the error, or make the error message better. I can drill down into code and try to patch things up, but I’d first need to know what to look for. _describe and _placeholder aren’t helping here :slight_smile:

I’d look for things related to wasm_bindgen

Things I’ve commonly seen are people targeting wasm32-unknown-unknown but assuming a JavaScript or browser-based host.

That might appear as a dependency on js_sys or web_sys

I ran into that here:

I think this is highly likely, since they specifically target this usecase - wasm in a browser.

I guess my question is more along the lines of “how can I make that error message more verbose”, to see what actual call triggers the error, so I can focus on that.

I believe the cause of the error is that the replica sees that your module is trying to import something it doesn’t provide.

You can’t do anything about that on the replica side so you’d need to change your Wasm module.

If you can’t change feature flags so that the produced module doesn’t try to import those functions, you can use wasm-snip to replace them with unreachable by doing something like:

wasm-snip input.wasm -o output.wasm __wbindgen_describe __wbindgen_placeholder

Then you should at least be able to install the module.

However, if you trigger something at runtime that actually tries to use one of those imports, you’ll hit unreachable and get a runtime error.