Skip to content

Need to consider "no fetch handler" situation in the spec update process #14

@azaika

Description

@azaika

After the static routing API is introduced, service worker registrations can be like the following:

self.addEventListener('install', async e => {
  await e.registerRouter([
    {
      condition: { requestMethod: 'GET' },
      source: 'cache'
    }
  ]);
  self.skipWaiting();
});

// no fetch handlers

This code expects all GET request to refer the service worker cache and does not register any fetch handlers.

However, it seems that the current ServiceWorker spec [1] does not consider the situation where no fetch handlers are registered.
For example, the "Handle Fetch" algorithm of the spec [2] stipulates that:

  1. If the result of running the Should Skip Event algorithm with "fetch" and activeWorker is true, then:

    1. If shouldSoftUpdate is true, then in parallel run the Soft Update algorithm with registration.
    2. Return null.

This means that service workers do not work if web developers do not write their own fetch handlers, and at least, the "Should Skip Event" algorithm should be updated.

[1] https://w3c.github.io/ServiceWorker/
[2] https://w3c.github.io/ServiceWorker/#on-fetch-request-algorithm

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