Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ndk.connect is asynchronous and doesn't respect timeout #290

Open
ktecho opened this issue Dec 23, 2024 · 0 comments
Open

ndk.connect is asynchronous and doesn't respect timeout #290

ktecho opened this issue Dec 23, 2024 · 0 comments

Comments

@ktecho
Copy link

ktecho commented Dec 23, 2024

When trying to publish events, I try doing this:

await ndk.connect(5000);
const ndkEvent = new NDKEvent(ndk);
ndkEvent.xxx = xxx
await ndkEvent.publish()

That fails from time to time with NDKPublishError: Not enough relays received the event.

If I wait for 5 seconds, then it always works:

await ndk.connect(5000);
await new Promise(resolve => setTimeout(resolve, 5000));
const ndkEvent = new NDKEvent(ndk);
ndkEvent.xxx = xxx
await ndkEvent.publish()

I think that's a bug, because the timeout should wait 5 seconds before returning. I see this in ndk's code: If the timeout is reached, the connection will be continued to be established in the background.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant