-
Notifications
You must be signed in to change notification settings - Fork 54
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(yamux): future leak #1171
fix(yamux): future leak #1171
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1171 +/- ##
========================================
Coverage 84.53% 84.54%
========================================
Files 91 92 +1
Lines 15517 16424 +907
========================================
+ Hits 13118 13885 +767
- Misses 2399 2539 +140
|
await closedRemotelyFut.cancelAndWait() | ||
if not receivedDataFut.finished(): | ||
await receivedDataFut.cancelAndWait() | ||
await closedRemotelyFut or receivedDataFut |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is probably better to use
proc raceCancel*(
futs: seq[InternalRaisesFuture]
): Future[FutureBase] {.async: (raises: [ValueError, CancelledError]).} =
try:
discard await race(futs)
finally:
await noCancel allFutures(futs.filterIt(not it.finished).mapIt(it.cancelAndWait))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's also going to handle cancelations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a huge fan of using InternalRaisesFuture
outside of Chronos tbh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me neither, but that's the only way for now, unless SomeFuture is changed to public.
At first glance, this fixes #1165.
It raises another issue: I always thought that Future unfinished caught in the GC were cancelled. But that doesn't always seem to be the case.