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

fix: Asynchronous task [sendMsgSlow()] was cancelled [FutureDefect] #1094

Merged
merged 1 commit into from
May 7, 2024

Conversation

diegomrsantos
Copy link
Collaborator

Fix for:

crash on Nimbus 24.4.0 in production 9:03 EDT. 09:03:24.578950-04:00 localhost nimbus-beacon[4803]: Error: unhandled exception: Asynchronous task [sendMsgSlow() at pubsubpeer.nim:301] was cancelled! [FutureDefect]

Using await on a shared Future can raise an unexpected CancelledError if this Future gets canceled indirectly by another task. race (and join in newer versions of chronos) creates a separate future that "insulates" the shared future from the cancellation flow. See status-im/nim-chronos@8166d7d#diff-a6bc56e6ac55acab484b1a94671287d6f72bc6311b3ea43482b438b517ec9390R172.

@arnetheduck arnetheduck merged commit 88e233d into master May 7, 2024
9 checks passed
@arnetheduck arnetheduck deleted the cancel-fix branch May 7, 2024 13:44
@@ -304,7 +304,7 @@ proc sendMsgSlow(p: PubSubPeer, msg: seq[byte]) {.async.} =
if p.sendConn == nil:
# Wait for a send conn to be setup. `connectOnce` will
# complete this even if the sendConn setup failed
await p.connectedFut
discard await race(p.connectedFut)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not join(p.connectedFut)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not in the chronos release libp2p uses

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

Successfully merging this pull request may close these issues.

3 participants