Opened 7 years ago

Closed 7 years ago

#15732 closed defect (fixed)

xhr.abort gives different error messages on different browsers/ cannot use deferred since it is not published

Reported by: Paul Christopher Owned by: Bryan Forbes
Priority: blocker Milestone: 1.8
Component: IO Version: 1.8.0rc1
Keywords: Cc:
Blocked By: Blocking:

Description

Description

Calling response.xhr.abort from within a request.notify send callback triggers the original request's error callback. However the error message string seems to depend on the browsers being used. Firefox gives you "Cannot modify properties of a WrappedNative", Safari "INVALID_STATE_ERR: DOM Exception 11". Thus there is no simple and uniform way to treat an xhr abort in the error callback.

Resolving/ rejecting the deferred with a custom reason is not an option either: The deferred is not published with the synthetic event (The IO pipeline topics used to publish the deferred, too. Why does the new request module not publish it? Is this by design?).

Steps to reproduce the issue

Run the attached test case on different browsers. Observe the console output. The error message is different in IE, Firefox, Safari.

Discussion

This is a real life example in a very reduced form. It tries to catch all ajax activities and cancel them if the session on the server has timed out. This can be easily done with the old IO pipeline topics but seems not to be possible anymore with the new request module: The request module does not publish the deferred, aborting the requests does not trigger a uniform error message.

Attachments (1)

Index.cshtml (1.4 KB) - added by Paul Christopher 7 years ago.
Test file ("view") taken from an asp.net mvc3 project

Download all attachments as: .zip

Change History (3)

Changed 7 years ago by Paul Christopher

Attachment: Index.cshtml added

Test file ("view") taken from an asp.net mvc3 project

comment:1 Changed 7 years ago by Bryan Forbes

In [29379]:

Pass promise's cancel() to "send" event in dojo/request/notify. refs #15732 !strict

comment:2 Changed 7 years ago by Bryan Forbes

Milestone: tbd1.8
Priority: undecidedblocker
Resolution: fixed
Status: newclosed

Because calling response.xhr.abort() does not go through the deferred's mechanism, it won't trigger an error. However, I have modified the "send" event to have a second argument which is the promise's cancel() function. Calling it will cancel the XHR properly and also trigger the error condition. I also added a test case in the notify tests for the cancel function.

Note: See TracTickets for help on using tickets.