rust-libp2p
rust-libp2p copied to clipboard
gossipsub: Uncaught TypeError when running in the browser
Summary
When running an application using libp2p-gossipsub targeting wasm32 in the browser, it seems an error Uncaught TypeError: The specifier “env” was a bare specifier, but was not remapped to anything. Relative module specifiers must start with “./”, “../” or “/”. is produced. After inspection, it points to futures-ticker, which still depends on instant. Previously this was not a problem because we used to have the feature enabled up until https://github.com/libp2p/rust-libp2p/pull/5347 was merged.
Keep in mind, this is just by it being included. It does not have to run the code itself.
Expected behavior
For the application to run in the browser
Actual behavior
Gives an error in console
Relevant log output
No response
Possible Solution
- Add
instant = { version = "0.1.13", features = ["wasm-bindgen"] }to libp2p-gossipsub when targeting wasm32; or - Submit PR to
futures-tickerto enable this feature for wasm32 target (or replace it withweb-time); or - Replace
futures-tickerwith in-house code that performs similar or the same behaviour.
Version
0.54.1 and master
Would you like to work on fixing this bug ?
Maybe