BackgroundFetchRegistration: failureReason property

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

Note: This feature is available in Web Workers.

The failureReason read-only property of the BackgroundFetchRegistration interface returns a string with a value that indicates a reason for a background fetch failure.

If the value of this property changes, the progress event is fired at the associated BackgroundFetchRegistration object.

Value

One of the following strings:

""

The background fetch has not completed, or was successful.

"aborted"

The operation was cancelled by the user, or abort() was called.

"bad-status"

A response had a not-ok status (a status outside the range 200-299).

"fetch-error"

A fetch failed for other reasons, for example CORS, or a network failure.

"quota-exceeded"

Storage quota was reached during the operation.

"download-total-exceeded"

The provided downloadTotal was exceeded. This value was set when the background fetch was registered.

Examples

Logging this property to the console prints the reason the fetch failed, or an empty string if it was successful or has not yet completed.

js
console.log(bgFetch.failureReason);

Specifications

Specification
Background Fetch
# dom-backgroundfetchregistration-failurereason

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
failureReason
Experimental

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Experimental. Expect behavior to change in the future.