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

fetch: limit web streams usage in body mixin methods #3113

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/web/fetch/response.js
Expand Up @@ -146,7 +146,7 @@ class Response {
// 4. If body is non-null, then set bodyWithType to the result of extracting body.
if (body != null) {
const [extractedBody, type] = extractBody(body)
bodyWithType = { body: extractedBody, type }
bodyWithType = { body: extractedBody, type, source: body }
}

// 5. Perform initialize a response given this, init, and bodyWithType.
Expand Down
5 changes: 5 additions & 0 deletions lib/web/fetch/util.js
Expand Up @@ -1055,6 +1055,11 @@ async function fullyReadBody (body, processBody, processBodyError) {
// with taskDestination.
const errorSteps = processBodyError

if (typeof body.source === 'string') {
successSteps(new TextEncoder().encode(body.source))
Copy link
Contributor

@Uzlopak Uzlopak Apr 13, 2024

Choose a reason for hiding this comment

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

I did not check your code and if this makes sense. But I think this wil break without-intl builds . check how we implemented utf8Decode and look if you can implement something like utf8Encode?!

Copy link
Member Author

Choose a reason for hiding this comment

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

thank you very much for your suggestion I will try this

mertcanaltin marked this conversation as resolved.
Show resolved Hide resolved
return
}

// 4. Let reader be the result of getting a reader for body’s stream.
// If that threw an exception, then run errorSteps with that
// exception and return.
Expand Down