ergoplatform / ergoplatform/sigma-rust

Fix crash in getrandom on Electron/Vue desktop app

Open
#623 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
78
Forks
63
Avg merge
22h 5m
Merged PRs (30d)
3

Description

Attempted to fix in #620

trace:
```
panicked at 'could not initialize thread_rng: Node.js crypto module is unavailable', /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.8.5/src/rngs/thread.rs:72:17

Stack:

Error
at __wbg_new_693216e109162396 (webpack-internal:///./node_modules/ergo-lib-wasm-browser/ergo_lib_wasm_bg.js:6914:17)
at console_error_panic_hook::hook::h992992de3f0fa9b9 (wasm://wasm/00ffe776:wasm-function[1812]:0x198005)
at core::ops::function::Fn::call::hc810e5369804b9f1 (wasm://wasm/00ffe776:wasm-function[10901]:0x29a677)
at std::panicking::rust_panic_with_hook::h1c368a27f9b0afe1 (wasm://wasm/00ffe776:wasm-function[2967]:0x1e955f)
at std::panicking::begin_panic_handler::{{closure}}::h8e1f8b682ca33009 (wasm://wasm/00ffe776:wasm-function[4676]:0x236ce4)
at std::sys_common::backtrace::__rust_end_short_backtrace::h7f7da41799766719 (wasm://wasm/00ffe776:wasm-function[9950]:0x2973b2)
at rust_begin_unwind (wasm://wasm/00ffe776:wasm-function[7859]:0x281b8c)
at core::panicking::panic_fmt::hcdb13a4b2416cf82 (wasm://wasm/00ffe776:wasm-function[7922]:0x2829f3)
at std::thread::local::lazy::LazyKeyInner::initialize::hc4dfa70367192fbc (wasm://wasm/00ffe776:wasm-function[1709]:0x18ea94)
at rand::rngs::thread::THREAD_RNG_KEY::__getit::h8a182064bee393d6 (wasm://wasm/00ffe776:wasm-function[9567]:0x295009)
```

Fix:
> Looks like this https://github.com/rust-random/getrandom/issues/256#issuecomment-1152904556 works 🥳
> still running some tests but that seems to be the solution for us. Using browser wasm version and adding the at the end of the bindings file

Even better fix:
Figure out why `cardano-serialization-lib` JS bindings work and use the same approach.

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.