← Back to release summary

ServiceWorker Static Routing: Distinct TypeError message for cancelled race-network-and-fetch-handler fetch() requests

Category
Miscellaneous
Type
New or changed feature
Status
Proposed (Chrome Proposed)
Intent stage
None

WPT details: Because TypeError message strings are implementation-defined and vary across browser engines, WPT only asserts the exception type. Tested in Chromium browser tests (content/browser/service_worker/service_worker_browsertest.cc) and Blink unit tests (third_party/blink/renderer/modules/service_worker/service_worker_global_scope_test.cc).

Summary

When a Service Worker matches a Static Routing rule with 'race-network-and-fetch-handler' and calls fetch(event.request) inside its fetch handler, Chromium deduplicates the network request. If that raced request is cancelled before response headers arrive (net::ERR_ABORTED)—for example, when an offline fallback timer resolves event.respondWith() first or the navigation is aborted—Chromium now rejects the fetch(event.request) promise with TypeError("The service worker race-network-and-fetch-handler request was cancelled before 'fetch()' settled.") instead of the generic TypeError("Failed to fetch"). This matches Service Worker Navigation Preload (event.preloadResponse) and allows web applications to distinguish expected pre-settlement race cancellations from genuine network errors. Note: This is a small behavioral refinement to the already-shipped Service Worker Static Routing API with no IDL or specification changes. Because web applications may observe the updated TypeError message string, we are sending an Intent to Ship directly for web compatibility review.

Motivation

In Service Worker Navigation Preload (event.preloadResponse), Chromium already distinguishes pre-settlement cancellation (net::ERR_ABORTED) from genuine network failures by rejecting event.preloadResponse with "The service worker navigation preload request was cancelled before 'preloadResponse' settled.". Offline-capable web applications migrating from Navigation Preload to Static Routing ('race-network-and-fetch-handler') inspect this cancellation message to suppress expected cancellation noise in client error telemetry while still alerting on genuine network outages. Because 'race-network-and-fetch-handler' currently collapses net::ERR_ABORTED into TypeError("Failed to fetch"), migrating causes false-positive network error spikes and triggers unnecessary offline fallback paths.

Standards & signals

Ecosystem

Explainers: https://crbug.com/584504247

View on chromestatus.com