-
-
Notifications
You must be signed in to change notification settings - Fork 3
feat: deserializeAsync uses streams to pipe values
#32
Conversation
deserializeAsync uses streams to pipe values
Codecov ReportAttention:
📢 Thoughts on this report? Let us know!. |
| for (const controller of cache.values()) { | ||
| controller.error(err); |
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.
Can you call .error() after it's closed?
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.
.error yes I believe, this method just makes it so that any future interaction with the stream will error, it is not an error by itself.
| return; | ||
| } | ||
| let next: ReadableStreamReadResult<SerializedIteratorResult>; | ||
| while (((next = await opts.reader.read()), !next.done)) { |
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.
This could prob be prettier :D
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.
TBH, while(true) and if(next.done) return would have worked fine, but then eslint doesn't like while(true) so I went with this. We can eslint-disable-next-line instead if you prefer.
| case ITERATOR_ERROR: { | ||
| opts.controller.close(); | ||
| throw TsonPromiseRejectionError.from(next.value[1]); | ||
| } |
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 guess we need to test this with that warning
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.
Yeah we need to add tests for
- tsonAsyncIterable
- more weird cases for deserializeAsync to make sure everything errors and closes correctly
…ialize-async/use-streams-to-pipe-values
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.
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.
deserializeAsyncuses aReadableStreamfor each of the async values. This allows forcontroller.enqueueto add values (single value for Promise, as many values as we want for AsyncIterator)controller.closefrom anywhere without needing anonDonecallback