[Webkit-unassigned] [Bug 284184] New: Checking for presence of request body in Service Worker causes body to be dropped from request

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Dec 6 12:35:26 PST 2024


https://bugs.webkit.org/show_bug.cgi?id=284184

            Bug ID: 284184
           Summary: Checking for presence of request body in Service
                    Worker causes body to be dropped from request
           Product: WebKit
           Version: Safari 18
          Hardware: All
                OS: All
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: Service Workers
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: wes at goulet.dev
                CC: youennf at gmail.com

If a service worker intercepts a fetch request and checks for the presence of a body then the body will get dropped from the SW's fetch request.

NOTE: I have tried this with both "Content-Type: application/json" and "Content-Type: x-www-form-urlencoded" and both hit this bug.


> // sw code
> self.addEventListener("fetch", (event) => {
>  event.respondWith(
>    (async () => {
>      if (event.request.body) {
>        console.log("this request has a body");
>      }
>      return fetch(event.request);
>    })()
>  );
>});

I have made a repro at https://github.com/wes-goulet/webkit-service-worker-drop-body-repro

This same check of a request body causes no issue if it happens on the main thread (not in SW).

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20241206/a9dc0bee/attachment.htm>


More information about the webkit-unassigned mailing list