Bug 284184
| Summary: | Checking for presence of request body in Service Worker causes body to be dropped from request | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Wes <wes> |
| Component: | Service Workers | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | achristensen, annevk, cdumez, webkit-bug-importer, youennf |
| Priority: | P2 | Keywords: | InRadar |
| Version: | Safari 18 | ||
| Hardware: | All | ||
| OS: | All | ||
| See Also: | https://github.com/web-platform-tests/wpt/pull/49923 | ||
Wes
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).
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/141454387>
youenn fablet
Submitted web-platform-tests pull request: https://github.com/web-platform-tests/wpt/pull/49923
EWS
Committed 288514@main (6c800745251d): <https://commits.webkit.org/288514@main>
Reviewed commits have been landed. Closing PR #38561 and removing active labels.