Open Bug 1671309 Opened 4 years ago Updated 3 years ago

Fetch promise is rejected on page unload, unlike other browsers

Categories

(Core :: DOM: Networking, defect, P3)

defect

Tracking

()

Tracking Status
firefox81 --- affected
firefox82 --- affected
firefox83 --- affected

People

(Reporter: s, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [necko-triaged])

Attachments

(1 file)

649 bytes, application/x-php
Details
Attached file navdemo.php

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36

Steps to reproduce:

Go to the demo page at http://ilo.nfshost.com/tests/navdemo.php (source attached).

Click "Navigate". This will begin a fetch request (which will not complete immediately as the server side sleeps for 5 seconds), then navigate to a new page.

Actual results:

The Promise returned by the fetch is rejected with "TypeError: NetworkError when attempting to fetch resource.". This error will be displayed on the page as JavaScript continues running while the navigation is pending.

This means that if you have a web application with error handling, and you navigate to another page while a request is in progress, the user will see an error message for a second or two (however long the new page takes to load).

The same issue is present with XHR as well, except it is treated as an abort.

Expected results:

The promise should not have been rejected. Other browsers do not reject the promise/abort the request upon navigation, or if they do, they do not report it to the page JavaScript.

I've tested Chrome (with and without the bfcache feature flag), Safari, and Edge Legacy and they do not abort the request upon page navigation.

This is also how Firefox 44 and below behaves. The rejections only started happening with Firefox 45.

Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0

Hi,

I have managed to reproduce it on Release version 81.0.2, Beta 82 and latest Nightly 83.0a1 (2020-10-18) using Windows 10.
Further, I will move this over to a component so developers can take a look over it. If this is not the correct component please feel free to change it to an appropriate one.
Note that I am able to reproduce this with Firefox 42 as well. Not reproducible in Chrome.

Thanks for your input.

Status: UNCONFIRMED → NEW
Component: Untriaged → DOM: Networking
Ever confirmed: true
OS: Unspecified → All
Product: Firefox → Core
Hardware: Unspecified → All
Version: Firefox 81 → Trunk

According to Anne this behaviour isn't mandated by the spec.

Blocks: fetch
Severity: -- → S3
Priority: -- → P2
Whiteboard: [necko-triaged]

It would be good to know what other browsers do here. Do they abort the request? At the same time or a different time? Silently aborting is an option we have I suppose though I'm not sure how that should work with bfcache.

I would expect active fetch to prevent the page to enter bfcache.

See Also: → 896666
Priority: P2 → P3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: