-
Notifications
You must be signed in to change notification settings - Fork 630
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
abortableAsyncIterable()
should call .return()
on the generator once aborted
#3518
Labels
Comments
Closed
Contributions are welcome 🙂 |
iuioiua
changed the title
abortableAsyncIterable should call return on the generator once aborted
Dec 30, 2023
abortableAsyncIterable()
should call .return()
on the generator once aborted
const stream = source
.pipeThrough(new TextDecoderStream())
.pipeThrough(new TextLineStream({ allowCR: true }))
try {
for await (const message of abortable(stream, signal)) {
this.dispatch({ message });
}
} catch (e) {
console.error(e)
} this results with:
and when trying to
|
@iuioiua Interestingly this works when stream is created by fetch for example but I'm having strange errors when using streams created in code but this is a problem with deno itself I think. Reported it here: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
Async generators canceled by
abortableAsyncIterable
don't have theirreturn
method called, so they don't get the opportunity to clean up resources.https://github.com/denoland/deno_std/blob/d84f4b1c947b6b09df5e9a2e50e8f1549fe615fd/async/abortable.ts#L135-L139
Expected behavior
An example of a library which handles this is abortable-iterator:
https://github.com/alanshaw/abortable-iterator/blob/68c554cb40bd160216abb7200b54015aad0bd9a8/src/index.ts#L103-L106
Environment
The text was updated successfully, but these errors were encountered: