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

Unhandled rejection when calling lightPush send #1569

Closed
agazso opened this issue Sep 14, 2023 · 0 comments · Fixed by #1584
Closed

Unhandled rejection when calling lightPush send #1569

agazso opened this issue Sep 14, 2023 · 0 comments · Fixed by #1584
Assignees
Labels
bug Something isn't working

Comments

@agazso
Copy link

agazso commented Sep 14, 2023

This is a bug report

Problem

I have a long running Node.js application (think of a chat bot) that uses waku lightPush. Occasionally there are some uncaught rejections caught at the top-level when invoking waku.lightPush.send.

The problem with this that sending the message fails, but even though I have a try..catch around send the exception is generated at top level as an uncaught rejection. This indicates that there is a promise call somewhere under send which is rejected but the error is not handled, so it bubbles up.

It makes it very difficult to detect if sending fails so that it can be retried at the right context in the code. In Node.js you can install a top-level handler for unhandled rejections, but at that point there is missing context to what failed. Ideally the send function should not even generate exceptions, because its API returns an error if there were any, so it should capture all exceptions, including rejected promises.

The root cause of the problem seems to be the same as issue #1563 and I haven't seen it happening with @waku/sdk version 0.0.16, only with versions starting from 0.0.17.

Notes

@waku/sdk version 0.0.17, 0.0.18, 0.0.19 (the latest working that I tried was 0.0.16)
Node.js v18.17.1 on Linux
Connected to nwaku 0.18


Error: Failed to get a connection to the peer
    at StreamManager.newStream (/home/attila/Projects/LogosLab/waku-objects-playground-bot/node_modules/.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@waku/core/src/lib/stream_manager.ts:52:13)
    at StreamManager.prepareNewStream (/home/attila/Projects/LogosLab/waku-objects-playground-bot/node_modules/.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@waku/core/src/lib/stream_manager.ts:58:32)
    at StreamManager.getStream (/home/attila/Projects/LogosLab/waku-objects-playground-bot/node_modules/.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@waku/core/src/lib/stream_manager.ts:37:10)
    at LightPush.getStream (/home/attila/Projects/LogosLab/waku-objects-playground-bot/node_modules/.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@waku/core/src/lib/base_protocol.ts:40:31)
    at <anonymous> (/home/attila/Projects/LogosLab/waku-objects-playground-bot/node_modules/.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@waku/core/src/lib/light_push/index.ts:107:33)
    at Array.map (<anonymous>)
    at LightPush.send (/home/attila/Projects/LogosLab/waku-objects-playground-bot/node_modules/.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@waku/core/src/lib/light_push/index.ts:105:28)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at sendMessage (/home/attila/Projects/LogosLab/waku-objects-playground-bot/src/lib/adapters/waku/waku.ts:117:20)
    at safeSendMessage (/home/attila/Projects/LogosLab/waku-objects-playground-bot/src/lib/adapters/waku/bot.ts:343:12)

@fryorcraken fryorcraken added this to Waku Sep 14, 2023
@fryorcraken fryorcraken self-assigned this Sep 20, 2023
@fryorcraken fryorcraken added the bug Something isn't working label Sep 20, 2023
fryorcraken added a commit that referenced this issue Sep 20, 2023
I can see this test reproduces #1569 because of the following log line:

`(node:347036) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 12)`

Unfortunately, I was not able (yet) to make the test fail.
@fryorcraken fryorcraken moved this to In Progress in Waku Sep 20, 2023
@fryorcraken fryorcraken moved this from In Progress to Code Review / QA in Waku Sep 20, 2023
@github-project-automation github-project-automation bot moved this from Code Review / QA to Done in Waku Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants