Module imports function '__wbindgen_object_drop_ref' from '__wbindgen_placeholder__' that is not exported by the runtime

Hey guys, here is a problem, I built a project and the compilation passed, but an error was reported during local deploy, here is the error message:

Error: Failed while trying to deploy canisters.
Caused by: Failed while trying to install all canisters.
Caused by: Failed to install wasm module to canister 'exchange-rate-backend'.
Caused by: Failed during wasm installation call
Caused by: The replica returned a rejection error: reject code CanisterError, reject message Error from Canister bkyz2-fmaaa-aaaaa-qaaaq-cai: Canister's Wasm module is not valid: Wasm module has an invalid import section. Module imports function
'__wbindgen_object_drop_ref' from '__wbindgen_placeholder__' that is not exported by the runtime..
This is likely an error with the compiler/CDK toolchain being used to build the canister. Please report the error to IC devs on the forum: https://forum.dfinity.org and include which language/CDK was used to create the canister., error code None

The ‘Cargo.toml’ are below:

[package]

name = "exchange-rate-backend"

version = "0.1.0"

edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]

crate-type = ["cdylib"]

[dependencies]

candid = "0.10"

ic-cdk = "0.13"

ic-cdk-timers = "0.7" # Feel free to remove this dependency if you don't need timers

serde = "1.0.192"

serde_json = "1.0"

ic-cdk-macros = "0.8.1"

reqwest = { version = "0.11", features = ["json"] }

What’s more, I don’t remember when I import ‘wbindgen_placeholder’, and also don’t how it came into my project

There may be an issue in reqwest that is trying to be web compatible. I would seek for features to turn on or off in reqwest to stop Wasm bindgen.

Does reqwest work from within a canister? I would guess not

Thank you @lastmjs, I deleted reqwest in Cargo.toml and deployed my canister successfully, maybe there are some conflicts between reqwest and other dependencies

@lastmjs @ydr990318
I also have same issue:
The replica returned a rejection error: reject code CanisterError, reject message Error from Canister bkyz2-fmaaa-aaaaa-qaaaq-cai: Canister’s Wasm module is not valid: Wasm module has an invalid import section. Module imports function ‘__wbindgen_object_drop_ref’ from ‘wbindgen_placeholder’ that is not exported by the runtime…
This is likely an error with the compiler/CDK toolchain being used to build the canister. Please report the error to IC devs on the forum: https://forum.dfinity.org and include which language/CDK was used to create the canister., error code None

and Cargo.toml is this:
[package]
name = “daoV1_backend”
version = “0.1.0”
edition = “2021”

[lib]
crate-type = [“cdylib”]

[dependencies]
candid = “0.10”
ic-cdk = “0.17.0”
ic-cdk-timers = “0.11” # Feel free to remove this dependency if you don’t need timers
ic-stable-structures = “0.6.6”
serde = “1.0.215”
ic-cdk-macros = “0.17.0”
#chrono = “0.4.38”

It’s probably chrono, look through the features to only enable what you need. chrono is probably importing something for a web environment by default.

1 Like

I remove the chrono and it works