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

workbox-streams does not handle opaque responses properly #2998

Closed
jeffposnick opened this issue Dec 13, 2021 · 1 comment · Fixed by #3001
Closed

workbox-streams does not handle opaque responses properly #2998

jeffposnick opened this issue Dec 13, 2021 · 1 comment · Fixed by #3001
Assignees
Labels
Bug An issue with our existing, production codebase. workbox-streams

Comments

@jeffposnick
Copy link
Contributor

Library Affected:
workbox-streams

The following code in workbox-streams will break for opaque responses (as well as opaque redirected responses):

function _getReaderFromSource(
source: StreamSource,
): ReadableStreamReader<unknown> {
if (source instanceof Response) {
return source.body!.getReader();
}
if (source instanceof ReadableStream) {
return source.getReader();
}
return new Response(source as BodyInit).body!.getReader();
}

We shouldn't assume that the response body always exposes getReader().

@jeffposnick jeffposnick added Bug An issue with our existing, production codebase. workbox-streams labels Dec 13, 2021
@jeffposnick jeffposnick self-assigned this Dec 13, 2021
@jeffposnick
Copy link
Contributor Author

...actually, I think we just need some logic here to detect whether source.type is 'opaque' or 'opaqueredirect' and log a meaningful error, as there isn't much we can do to combine an opaque body in a non-opaque response stream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug An issue with our existing, production codebase. workbox-streams
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant