w3c / w3c/ServiceWorker

What happens to the request body if the fetch isn't handled?

Open
#1,191 15 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Bikeshed
Stars
3.6k
Forks
324
Avg merge
14d 22h
Merged PRs (30d)
1

Description

What happens if:

  • POST request with body.
  • The service worker does not call respondWith.
  • After 100ms (using waitUntil) the service worker tries to read the body of the request.

It feels like the read should fail, since the body is used as part of making the default request.

Test – Both Firefox and Chrome allow the body to be read, as if it's a clone.

I'm not sure this behaviour is compatible with request body streams. Or, it isn't memory-friendly.

Also, what happens if:

  • POST request with body.
  • The service worker gets a lock on the request's stream, tries to read data.
  • The service worker does not call respondWith.

It feels like this should result in a network error, as the browser won't be able to read from the stream.

Test – Both Firefox and Chrome allow the body to be read in the service worker, and allow the default request to happen.

Again, I think this is problematic with request body streams.

Shall we try and change this?

@annevk @wanderview

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked test and review the issue's scenarios involving POST bodies, respondWith, waitUntil, and request-stream reads. Determine the intended behavior when respondWith is not called and when the stream is locked, then document or test an agreed specification outcome for both cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
web-dev
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.