Skip to content

Getting errored/closed reader, Auto-releasing reader, Forcible cancel() on a stream #297

@yutakahirano

Description

@yutakahirano

I read @domenic's pull request and would like to talk about getting / releasing reader. If you think the PR is the right place to discuss, feel free to close this issue.

getReader() should succeed on closed stream

Imagine we have a Response (in Fetch API) res.
res.body.getReader() should succeed even when the response has an empty body. That means res.body.getReader() should succeed when the body is closed. The result is a closed reader.

getReader() should succeed on errored stream

Mainly for being consistent with the closed case. We do not lose anything by allowing this. The result is an errored reader.

Do we need auto-release?

Currently a reader is automatically released when it is closed or errored. Do we need the functionality?
It was introduced at #251 (comment), but given that our API is simpler than before and the current API requires a user to be sane, I would like to revisit the problem.

Concern: What happens when canceled via stream? What happens when canceled via reader?

Do we need .closed in stream?

I don't think of a use case. If we drop it, Resource management of Response.body will be much simpler.

The usefulness may depend on whether if keep auto-release or not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions