Open Bug 1392208 Opened 7 years ago Updated 2 years ago

XMLHttpRequest onerror isn't called when uploading a file

Categories

(Core :: DOM: Events, defect, P2)

55 Branch
defect

Tracking

()

UNCONFIRMED

People

(Reporter: daitheflu, Unassigned)

Details

Attachments

(1 file)

Attached file Basic example
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:55.0) Gecko/20100101 Firefox/55.0
Build ID: 20170814073321

Steps to reproduce:

I'm developping an upload form and I'd like the users to be able to resume their uploads if something wrong happens. For example, it they lose connection to the Internet.

(This happens on Firefox 55.0.2 64bits on macOS 10.12.6 - haven't been able to test other platforms).

0. Put the provided test page on a server somewhere and open it using Firefox ;
1. Open the developer console, messages will appear here ;
2. In the form, pick a decently big file, so you have the time to complete the next steps ;
3. Click the upload button : upload starts, you can see the progress in the console ;
4. Unplug your Internet cable or disable your Wi-Fi connexion ;
5. The upload stops (no more progress in the console) ;
6. The onerror handler isn't executed, nothing is printed in the console !
7. Re-plug or re-enable your Internet connexion, wait a bit for it to be up again... ;
8. Reload the page using Cmd+R ;
9. The ProgressEvent errors are displayed in the console !

Note: Do not just open the file locally (File > Open File...) using the "file://" protocol.


Actual results:

When the connexion is lost, the ProgressEvent error isn't triggered, so we can't handle it properly.
Worse: nothing happens, the request just seems to hang.


Expected results:

The ProgressEvent error should be triggered immediately and the onerror handler should be executed as well.
Component: Untriaged → DOM: Events
Product: Firefox → Core
Shawn might have ideas about what's up in our code.
Flags: needinfo?(shuang)
I guess it's related to bug 1362354. In theory, network error should trigger |OnStopRequest| and it's the same path that window.stop() would do. Unfortunately one test case would fail if patch in bug 1362354 got landed, so my patch can't land.
Since I just finished storage P2 bug, now I will switch my context to xhr again.

I will check this bug can be fixed by bug 1362354 or not today.
Flags: needinfo?(shuang)
(In reply to Shawn Huang [:shawnjohnjr] from comment #2)
> I guess it's related to bug 1362354. In theory, network error should trigger
> |OnStopRequest| and it's the same path that window.stop() would do.
> Unfortunately one test case would fail if patch in bug 1362354 got landed,
> so my patch can't land.
> Since I just finished storage P2 bug, now I will switch my context to xhr
> again.
> 
> I will check this bug can be fixed by bug 1362354 or not today.

It's a different problem. Please ignore my comment.
It looks like onStopRequest doesn't fire immediately. I guess we need to check IO notifications.

https://developer.mozilla.org/en-US/docs/Observer_Notifications#IO_Notifications
It looks like we should monitor topic:
"network:offline-about-to-go-offline" and "network:offline-about-to-go-offline", and run the request error steps for event error and exception NetworkError.
Priority: -- → P2
onaborted also isn't fired if abort() is called during the upload (neither on the XHR or on it's upload object). However, the request  *is* aborted (upload.loadend fires, but upload.load does not).
Oh, I see, this is only about the case when the network drops, not in general. I'll tweak bug 407754 to be about the case I just mentioned in comment 6.
No, it was my mistake, abort does fire, I just had a typo in my testcase. Sorry for the bugspam...

Would it be possible to at least modify this bug as CONFIRMED ?
That may shed some light on it.

Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: