Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

fix: handle unexpected end of stream #46

Merged
merged 16 commits into from
Oct 7, 2023
Merged

fix: handle unexpected end of stream #46

merged 16 commits into from
Oct 7, 2023

Conversation

KATT
Copy link
Member

@KATT KATT commented Oct 7, 2023

  • we can't know if a specific async type is done or not as it's the responsibility of the type itself
  • we can know if a stream is interrupted prematurely, so I added a check for that
  • we treat the "stream interrupted" as a message that we enqueue - if the interruption happens when the iterator has already consumed what it needs, we're all good

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

PR Compliance Checks

Thank you for your Pull Request! We have run several checks on this pull request in order to make sure it's suitable for merging into this project. The results are listed in the following section.

Issue Reference

In order to be considered for merging, the pull request description must refer to a specific issue number. This is described in our Contributing Guide. We are closing this pull request for now but you can update the pull request description and reopen the pull request.
The check is looking for a phrase similar to: "Fixes #XYZ" or "Resolves #XYZ" where XYZ is the issue number that this PR is meant to address.

@codecov
Copy link

codecov bot commented Oct 7, 2023

Codecov Report

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

Files Coverage Δ
src/async/asyncTypes.ts 100.00% <100.00%> (ø)
src/async/deserializeAsync.ts 97.80% <100.00%> (-1.28%) ⬇️
src/async/handlers/tsonAsyncIterable.ts 100.00% <100.00%> (+11.66%) ⬆️
src/async/serializeAsync.ts 96.40% <100.00%> (-0.02%) ⬇️
src/errors.ts 100.00% <ø> (+16.36%) ⬆️
src/index.ts 100.00% <100.00%> (ø)
src/internals/testUtils.ts 95.65% <100.00%> (+1.05%) ⬆️
src/async/handlers/tsonPromise.ts 92.95% <76.47%> (-1.96%) ⬇️
src/async/asyncErrors.ts 86.36% <86.36%> (ø)

📢 Thoughts on this report? Let us know!.

@KATT KATT requested a review from Sheraff October 7, 2023 14:07
Comment on lines +201 to +205
try {
controller.enqueue(err);
} catch {
// ignore if the controller is closed
}
Copy link
Member Author

Choose a reason for hiding this comment

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

I'd like to get rid of this try/catch 🤷

}

cache.clear();
Copy link
Member Author

Choose a reason for hiding this comment

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

We don't clear the cache because stuff can be listening

@KATT KATT merged commit 1efce87 into main Oct 7, 2023
@KATT KATT deleted the server-crash branch October 7, 2023 14:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants