You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Script crashes when you subscribe to relay(s) with reusing a single Filter instance.
The stack trace:
/home/jiftechnify/projects/code_samples/nostr/rust-nostr-js-sample/node_modules/@rust-nostr/nostr-sdk/pkg/nostr_sdk_js.js:15841
throw new Error(getStringFromWasm0(arg0, arg1));
^
Error: array contains a value of the wrong type
at module.exports.__wbindgen_throw (/home/jiftechnify/projects/code_samples/nostr/rust-nostr-js-sample/node_modules/@rust-nostr/nostr-sdk/pkg/nostr_sdk_js.js:15841:11)
at wasm://wasm/00f06292:wasm-function[5537]:0x245357
at wasm://wasm/00f06292:wasm-function[860]:0x14ef4e
at wasm://wasm/00f06292:wasm-function[3987]:0x2283bc
at wasm://wasm/00f06292:wasm-function[267]:0x99834
at wasm://wasm/00f06292:wasm-function[1033]:0x165e4b
at wasm://wasm/00f06292:wasm-function[4844]:0x2376be
at wasm://wasm/00f06292:wasm-function[5091]:0x23cb4b
at __wbg_adapter_52 (/home/jiftechnify/projects/code_samples/nostr/rust-nostr-js-sample/node_modules/@rust-nostr/nostr-sdk/pkg/nostr_sdk_js.js:248:10)
at real (/home/jiftechnify/projects/code_samples/nostr/rust-nostr-js-sample/node_modules/@rust-nostr/nostr-sdk/pkg/nostr_sdk_js.js:173:20)
To Reproduce
import{ClientBuilder,Filter,FilterOptions,loadWasmAsync,SubscribeAutoCloseOptions,}from"@rust-nostr/nostr-sdk";awaitloadWasmAsync();constclient=newClientBuilder().build();awaitclient.addRelays(["wss://nos.lol","wss://relay.nostr.band"]);awaitclient.connect();constfilter=newFilter().kind(1);console.log("sub to nos.lol");awaitclient.subscribeTo(["wss://nos.lol"],[filter],);console.log("sub to relay.nostr.band");awaitclient.subscribeTo(["wss://relay.nostr.band"],[filter],// reusing the filter here);
Expected behavior
No crash.
Build environment
Library: nostr-sdk
Language: JavaScript
Language version: Node.js v22.8.0
Tag/commit: v0.34.0
OS+version: Arch Linux
The text was updated successfully, but these errors were encountered:
Unfortunately it's an issue of wasm-bindgen: when an custom object is used in a list (Vec<T>) it's moved so can't be re-used.
Until this issue is solved on their side, I can temporary add a clone method on some objects (like Filter).
So would be:
constfilter=newFilter().kind(1);console.log("sub to nos.lol");awaitclient.subscribeTo(["wss://nos.lol"],[filter.clone()],// Clone here);console.log("sub to relay.nostr.band");awaitclient.subscribeTo(["wss://relay.nostr.band"],[filter],// Filter consumed here);
Describe the bug
Script crashes when you subscribe to relay(s) with reusing a single
Filter
instance.The stack trace:
To Reproduce
Expected behavior
No crash.
Build environment
The text was updated successfully, but these errors were encountered: