Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: b5aef3f0e4fc73299ec9f998007de512019041d3
      
https://github.com/WebKit/WebKit/commit/b5aef3f0e4fc73299ec9f998007de512019041d3
  Author: Youenn Fablet <[email protected]>
  Date:   2026-08-25 (Tue, 25 Aug 2026)

  Changed paths:
    M 
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event.https.h2-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event.https.h2.html
    M 
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/resources/fetch-event-test-worker.js
    M 
LayoutTests/platform/glib/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event.https.h2-expected.txt
    M LayoutTests/platform/mac-wk2/TestExpectations
    M Source/WebCore/Modules/fetch/FetchBody.cpp
    M Source/WebCore/Modules/fetch/FetchBody.h
    M Source/WebCore/Modules/fetch/FetchBodyOwner.cpp
    M Source/WebCore/Modules/fetch/FetchBodyOwner.h
    M Source/WebCore/Modules/fetch/FetchBodySource.h
    M Source/WebCore/Modules/fetch/FetchRequest.cpp
    M Source/WebCore/Modules/fetch/FetchRequest.h
    M Source/WebCore/Modules/fetch/FetchResponse.cpp
    M Source/WebCore/Modules/streams/ReadableStream.h
    M Source/WebCore/workers/service/FetchEvent.cpp
    M Source/WebCore/workers/service/FetchEvent.h
    M Source/WebCore/workers/service/context/ServiceWorkerFetch.cpp

  Log Message:
  -----------
  REGRESSION(317964@main): [macOS iOS] ASSERTION FAILED: bytesSent >= 
m_pendingStreamBytesSentByNetwork in 
imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event.https.h2.html
rdar://184253301
https://bugs.webkit.org/show_bug.cgi?id=321191

Reviewed by Chris Dumez.

318042@main started failing the load when the fetch event request body is 
disturbed,
since a body backed by a ReadableStream can no longer be provided

We need to support a service worker reading a clone of the request, even if the 
original request gets to the network.
PendingStreamState cannot have multiple consumers and we keep it this way for 
simplicity.

To implement the correct functional behavior, in case a fetch event request 
that has a pending stream body, the request is cloned
and the fetch event is not handled, we make the service worker do the fetch 
itself and we use this fetch for the fetch event.
This ensures that all request body data gets to the service worker and to the 
network, through the readable stream tee algorithm.
This also ensures that backward pressure is applied properly on the original 
readable stream.

 We now convert a pending stream FormData body into a ReadableStream before 
cloning it,
so that FetchBody::clone tees it as it does for any other stream body.
The original request keeps one branch and the clone gets the other, and each 
can be consumed independently.

Finally, when the fetch event is left unhandled, the request body is canceled, 
so the request is marked as disturbed to make it unusable afterwards, as per 
specification.

Covered by existing tests.

* 
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event.https.h2-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event.https.h2.html:
* 
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/resources/fetch-event-test-worker.js:
(handleCloneAndIgnore):
(handleCloneAfterIgnore):
(async self):
* 
LayoutTests/platform/glib/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event.https.h2-expected.txt:
* LayoutTests/platform/mac-wk2/TestExpectations:
* Source/WebCore/Modules/fetch/FetchBody.cpp:
(WebCore::FetchBody::clone):
* Source/WebCore/Modules/fetch/FetchBody.h:
(WebCore::FetchBody::setAsReadableStream):
(WebCore::FetchBody::isPendingStreamFormData const):
* Source/WebCore/Modules/fetch/FetchBodyOwner.cpp:
(WebCore::FetchBodyOwner::cloneBody):
(WebCore::FetchBodyOwner::hasClonedReadableStream const):
* Source/WebCore/Modules/fetch/FetchBodyOwner.h:
* Source/WebCore/Modules/fetch/FetchBodySource.h:
* Source/WebCore/Modules/fetch/FetchRequest.cpp:
(WebCore::FetchRequest::clone):
* Source/WebCore/Modules/fetch/FetchRequest.h:
* Source/WebCore/Modules/fetch/FetchResponse.cpp:
(WebCore::FetchResponse::clone):
* Source/WebCore/Modules/streams/ReadableStream.h:
(WebCore::ReadableStream::controller const):
* Source/WebCore/workers/service/FetchEvent.cpp:
(WebCore::FetchEvent::respondWith):
(WebCore::FetchEvent::processRespondWithPromise):
* Source/WebCore/workers/service/FetchEvent.h:
* Source/WebCore/workers/service/context/ServiceWorkerFetch.cpp:
(WebCore::ServiceWorkerFetch::dispatchFetchEvent):

Canonical link: https://commits.webkit.org/319788@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to