Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#3507 closed defect (fixed)

xhrGet prints error in Console when cancelling a download

Reported by: mumme Owned by: James Burke
Priority: high Milestone: 0.9beta
Component: Core Version: 0.9
Keywords: xhrGet, cancel Cc: alex
Blocked By: Blocking:


Hi !

I hope this not by design, there were no tests for cancel in tests/_base/xhr.html
So I can't tell for sure.

The scenario is this:

  1. start a xhrGet
  2. cancel the xhrGet in order to get a start another xhrGet

The console gets a row with 'xhr error in: XMLHttpRequest'
followed by: 'Error: Deferred Cancelled'
And then the errback chain is triggered.

To me this sounds counter intuative, as we usually know when we cancel a xhrGet.
I'm attaching a patch with a extended test.

Fredrik Johansson

Attachments (1)

xhr_cancel_without_errback.patch (1.3 KB) - added by mumme 15 years ago.
hum.. hope i get It right this time

Download all attachments as: .zip

Change History (7)

Changed 15 years ago by mumme

hum.. hope i get It right this time

comment:1 Changed 15 years ago by James Burke

I'm not sure we should prevent the error path from triggering on a deferred cancel. It could be that other pieces of code have attached callbacks to the IO's deferred (including nesting it in other deferreds). For those cases, it seems like we need to notify the other listeners that the deferred was canceled. I think it is worth doing the following though:

  • Change the Error object created in the cancel code path to attach a dojoType = "cancel" property to the error object, so listeners can determine in the error callback if it was a cancel, or timeout, or something else (right now the timeout path attaches an error.dojoType = "timeout").
  • Include the unit test that Fredrik has made to include testing of the dojoType == "cancel" on the cancel case.

I'll check with Alex though since he is the one that introduced the deferred model for the IO code.

comment:2 Changed 15 years ago by alex

Milestone: 0.9beta0.9

james: I think passing an error type makes sense. Lets get that done and documented for 0.9 final.

comment:3 Changed 15 years ago by alex

Cc: alex added

comment:4 Changed 15 years ago by Dustin Machi

Passing an error type is also the defined behavior for at least mochikits' implementation of deferreds for cancellation.

comment:5 Changed 15 years ago by James Burke

Resolution: fixed
Status: newclosed

(In [9411]) Fixes #3507: canceled deferreds get an error object with dojoType property of cancel.

comment:6 Changed 15 years ago by James Burke

Milestone: 0.90.9beta
Note: See TracTickets for help on using tickets.