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: remove abortable iterator #488

Merged
merged 1 commit into from
Feb 5, 2024
Merged

Conversation

achingbrain
Copy link
Collaborator

AbortableSource is slow because it races promises against every chunk causing extra async work.

It's only really necessary if we're going to pass the source off to another component.

Here we don't do that so it's simpler to just add a listener for the abort event and close the stream.

AbortableSource is slow because it races promises against every chunk
causing extra async work.

It's only really necessary if we're going to pass the source off to
another component.

Here we don't do that so it's simpler to just add a listener for the
abort event and close the stream.
@achingbrain achingbrain requested a review from a team as a code owner February 2, 2024 13:37
Comment on lines 66 to 67
// similar to pushable.end() but clear the internal buffer
await this.pushable.return()
Copy link
Collaborator Author

@achingbrain achingbrain Feb 2, 2024

Choose a reason for hiding this comment

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

I don't think this is necessary since the pushable is only referenced by this stream class so everything will be garbage collected shortly after the close method is called on this OutboundStream instance.

Suggested change
// similar to pushable.end() but clear the internal buffer
await this.pushable.return()

It's also worth noting that any queued messages will not be sent if you call .return instead of .end but this method is only called after the remote peer has already disconnected so it's not a big deal.

@codecov-commenter
Copy link

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (b4e6a8d) 81.40% compared to head (353fbcf) 81.39%.

Files Patch % Lines
src/stream.ts 88.88% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #488      +/-   ##
==========================================
- Coverage   81.40%   81.39%   -0.02%     
==========================================
  Files          48       48              
  Lines       12325    12333       +8     
  Branches     1301     1302       +1     
==========================================
+ Hits        10033    10038       +5     
- Misses       2292     2295       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@achingbrain
Copy link
Collaborator Author

#434 can probably be closed if this is merged.

@wemeetagain wemeetagain merged commit e39b2e2 into master Feb 5, 2024
9 checks passed
@wemeetagain wemeetagain deleted the fix/remove-abortable-source branch February 5, 2024 15:12
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

Successfully merging this pull request may close these issues.

None yet

3 participants