Skip to content

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

@jakearchibald

Description

@jakearchibald

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions