Closed Bug 1506797 Opened 7 years ago Closed 2 years ago

XMLHttpRequest.abort() doesn't actually cancel the request

Categories

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

63 Branch
defect

Tracking

()

RESOLVED INCOMPLETE

People

(Reporter: zurldan, Unassigned)

Details

(Whiteboard: [necko-triaged])

Attachments

(1 obsolete file)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:63.0) Gecko/20100101 Firefox/63.0 Steps to reproduce: Making a XMLHttpRequest with a arraybuffer responseType in order to fetch a file. Then running XMLHttpRequest.abort(). Actual results: Things that work when running abort() : The readyState is changed to XMLHttpRequest.UNSENT (0) The status code is set to 0. The onabort event is dispatched correctly. So it seems to work fine at first glance but in the background the request is still fetching the file. In the dev tools I can see the request still pending in the Network tab and it eventually completes with a HTTP 200 status code when the whole file has been fetched. Expected results: The request should not continue to fetch the file until completion in the background and the connection should close as soon as abort() is called.
Attachment #9024674 - Attachment is obsolete: true
I think this issue is the same as bug 1007109: abort() is not triggered, therefore duping after it.
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Resolution: --- → DUPLICATE
(In reply to Adrian Florinescu [:adrian_sv] from comment #2) > I think this issue is the same as bug 1007109: abort() is not triggered, > therefore duping after it. Hello, as stated in my report, i call abort() manually and the abort event is correctly dispatched since XMLHttpRequest.onabort function is executed. So i don't think this is the same issue here.
Fair point Zurldan, lets then reopen this issue and move it to its proper component for a better visibility. Could you please attach a reduced testcase in order to make sure everybody is on the same page?
Status: RESOLVED → UNCONFIRMED
Component: Untriaged → DOM: Events
Flags: needinfo?(zurldan)
Product: Firefox → Core
Resolution: DUPLICATE → ---
Component: DOM: Events → DOM: Networking
Priority: -- → P3

Maybe the condition at [1] excludes calling Cancel() on the underlying channel.

No, it calls CloseRequest() (the next function in the link given), which calls mChannel->Cancel(NS_BINDING_ABORTED).

In fact, I can't reproduce this with a test-case like the following:

  const x = new XMLHttpRequest();
  x.responseType = "arraybuffer";
  x.open("get", "large_file.tar.bz2");
  x.send();
  setTimeout(function() {
    x.abort();
  }, 50);

The devtools only shows whatever size was downloaded before the abort, and things seem to be working fine otherwise.

If anyone has a working test-case or definitive steps to reproduce this, it would help.

I noticed this behavior today and created a CodeSandbox:
https://codesandbox.io/embed/jovial-cori-h14yg

For this to work you need to enable network speed throttling to e.g. "regular 3g".

Then you'll see the request is still fetching the file and returning http 200.

I've validated this with Chrome 75, where the request gets cancelled as it should be.

Screenshot:

I'm having this same problem in Firefox Developer Edition 70.0.1. I am unable to abort file uploads. I have not yet tried aborting other types of requests.

Whiteboard: [necko-triaged]

(In reply to Krystof Beuermann from comment #7)

I noticed this behavior today and created a CodeSandbox:
https://codesandbox.io/embed/jovial-cori-h14yg

For this to work you need to enable network speed throttling to e.g. "regular 3g".

Then you'll see the request is still fetching the file and returning http 200.

I've validated this with Chrome 75, where the request gets cancelled as it should be.

Screenshot:

FWIW, I can't reproduce with this test case.

Severity: normal → S3

A needinfo is requested from the reporter, however, the reporter is inactive on Bugzilla. Given that the bug is still UNCONFIRMED, closing the bug as incomplete.

For more information, please visit BugBot documentation.

Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago2 years ago
Flags: needinfo?(zurldan)
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: