Skip to content

Commit

Permalink
Eliminate network fallback from ServiceWorkerContextRequestHandler.
Browse files Browse the repository at this point in the history
ServiceWorkerContextRequestHandler should emit a network error instead
of falling back to network when it cannot handle a request. Otherwise, a
service worker can be spawned that did not load via our custom
ServiceWorkerWriteToCacheJob/ServiceWorkerReadFromCacheJob jobs,
resulting in a running worker whose ServiceWorkerVersion has not
been properly initialized. I suspect this can cause the bug 485900.

This patch:
- Changes network fallback for failure cases to an ERR_FAILED network
  error.
- As an exception, an installed worker loading an unstored script still
  results in network fallback. This should be deprecated and removed
  eventually, see w3c/ServiceWorker#1021.
- Changes the behavior for a new worker loading an already stored script
  (i.e., calling importScripts() for the same script multiple times).
  Before this patch, we would fallback to network for this script. Now,
  we read the stored script. This is not yet codified in the spec but is
  expected to have almost no real-world impact and has support on
  w3c/ServiceWorker#1041

BUG=485900,678899

Review-Url: https://codereview.chromium.org/2602853002
Cr-Original-Commit-Position: refs/heads/master@{#442590}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 815dc48c9d00b0142a2421de8f10b7cb9c5b34ab
  • Loading branch information
mfalken authored and Commit bot committed Jan 10, 2017
1 parent 7bd8320 commit a7a9aa0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions log/net_log_event_type_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -2089,6 +2089,13 @@ EVENT_TYPE(SERVICE_WORKER_START_WORKER)
// }
EVENT_TYPE(SERVICE_WORKER_FETCH_EVENT)

// This event is emitted when a request for a service worker script or its
// imported scripts could not be handled.
// {
// "error": The error reason as a string.
// }
EVENT_TYPE(SERVICE_WORKER_SCRIPT_LOAD_UNHANDLED_REQUEST_ERROR)

// ------------------------------------------------------------------------
// Global events
// ------------------------------------------------------------------------
Expand Down

0 comments on commit a7a9aa0

Please sign in to comment.