Bug Tracker

Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#7787 closed bug (invalid)

Ajax abort triggers failure event

Reported by: kwooda@… Owned by: kwooda@…
Priority: undecided Milestone: 1.6
Component: ajax Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:

Description

I have an auto-suggest component that performs an Ajax look-up as you type, and it calls abort() if a previous look-up is already in progress. However, now in version 1.4.4, this intermittently triggers an onFailure event. The event handler gets error code 0 with an "unknown" error, which suggests to me the abort logic fails to detect that this was an intentional abort under some condition. Unfortunately, I cannot provide my code, but it has been in use for a very long time, and this issue appeared when I upgraded from jQuery 1.4.2 to 1.4.4.

Change History (12)

comment:1 Changed 9 years ago by anonymous

I forgot to mention this is in IE8

comment:2 Changed 9 years ago by kwooda@…

This line looks wrong - is this double .call.call intentional?

Function.prototype.call.call( oldAbort, xhr );

If I change this to: Function.prototype.call( oldAbort, xhr );

The problem I am having disappears.

comment:3 Changed 9 years ago by jitter

Component: unfiledajax
Owner: set to kwooda@…
Status: newpending

Thanks for taking the time to contribute to the jQuery project by writing a bug report.

Your report is missing a test case thus I made one myself. live test case. But I couldn't reproduce your problem. Also what is the "onFailure" event (sounds like Prototype/Mootools).

Please read How to report bugs (especially the "Try a newer version of jQuery" and the "What To Provide" section).

Also make a test case on http://jsfiddle.net which reproduces your problem (and no this doesn't mean to post your production code). Test also with the jQuery WIP version (as there are some big changes in the ajax code since the release of 1.4.4) to make sure this hasn't been fixed already.

Then please report back and provide more information (especially browser/os versions) and the link to the test case.

comment:4 Changed 9 years ago by dhchow22@…

I'm seeing the same behavior. I was able to repro the error with jitter's live test case (when you type in the input, the firebug console output shows "error undefined", showing that the error callback is called on every abort). I was able to repro this in Safari, FF, and IE8.

comment:5 in reply to:  3 Changed 9 years ago by kwooda@…

Status: pendingnew

The test case you have provided shows the error quite well. The problem shows up in IE8 (I have not tried Safari). Just type into the input box and see the error callback is called with every abort, as noted by dhchow22. As for "onFailure", that is simply the name of the callback function I assigned to the ajax error callback hook - sorry for the confusion.

comment:6 Changed 9 years ago by snover

Resolution: invalid
Status: newclosed

Thanks for the report, but this is not a jQuery bug.

The XHR spec does not provide a mechanism for determining whether or not a failed request was due to network error vs. an abortion, so it is not possible for jQuery to differentiate between them. There was a bug in 1.4.0-1.4.2 that caused error requests to be reported as successful; this was corrected in 1.4.3.

Unfortunately, because it’s impossible to override the abort handler in IE6, there is no way that jQuery can fix this issue in a fully cross-browser manner. Since both abortions and network failures do not result in a successful request, they both call the failure handler.

comment:7 Changed 9 years ago by kwooda@…

You guys have totally misinterpreted this issue. It is a bug. Aborting an Ajax event should not trigger an error event. You have what looks like an invalid line of JavaScript in your code that, when corrected, fixes the problem.

Change Function.prototype.call.call( oldAbort, xhr ); to Function.prototype.call( oldAbort, xhr );

This is a bug and needs to be addressed. If it is not re-opened, I will file a new one.

comment:8 Changed 9 years ago by jaubourg

Ajax has been highly re-architectured in the repository (1.4.5pre). The abort method of the native xhr is not dealt with like it used to be anymore.

Before crying "wolf", would you be so kind as to checkout jQuery from the repository and test your code against it or, at the very least, provide a minimal unit test we could include into jQuery's test chain to see if the issue is still there?

We want bugs to be solved as much as you do but you won't help us help you by refusing to provide a simple use case showing the bug.

You have to understand there are a lot of things that can go wrong in any Javascript code and, thus, *you* have to trim your code down to a minimal use case that makes it clear the problem is in ajax, not somewhere else. Then, we can use this code snippet, confirm the bug, include the test into our test suite, fix the issue and ensure it stays fixed for further releases. Saying "when I change line XXX, it's fixed" is not enough, seeing as you can't know what you're breaking by changing jQuery's code. On the other hand, we can assess that pretty easily... yet again, provided we have a usable test case.

So, to make it short: provide a use case that exhibits the bug against 1.4.5pre and the bug will be re-opened. In any other case, the bug stays invalid and closed.

comment:9 Changed 9 years ago by kwooda@…

There is a live test case for this issue that clearly shows the problem, which is why I do not understand the response here. Also, there appears to be no option available in JSFIDDLE for "1.4.5pre". I have also pointed out in my comments, if you care to read them, where the bug actually is in your code - again, bewilderment emerges in my mind.

Test case is at http://jsfiddle.net/jitter/HHwrT/ and all you have to do is open it in Internet Explorer (8) and type into the input field. You will see that whenever the Ajax update is aborted, the error handler is executed - which is incorrect behavior.

In jQuery 1.4.4 code, the following line can be found: Function.prototype.call.call( oldAbort, xhr ); If you change this to the following, the problem disappears: Function.prototype.call( oldAbort, xhr );

If you can point me to where I can find 1.4.5pre, or make it available in Fiddle, I'll be happy to test it out. In the meantime, however, the problem is there, clearly demonstrable, and with a solution on hand, so... please check it out.

comment:10 Changed 9 years ago by ajpiano

The 0 GIT version is a build from the latest revision of jQuery and can be considered to be 1.next-pre at any given time.

http://jsfiddle.net/ajpiano/HHwrT/8/

comment:11 in reply to:  10 Changed 9 years ago by kwooda@…

Replying to ajpiano: Thanks for the info - much appreciated.

I see the problem still exists.

comment:12 Changed 8 years ago by anonymous

You just need to do proper ajax request

use $.ajax with global:false option

Note: See TracTickets for help on using tickets.