Bug Tracker

Modify

Ticket #9687 (closed bug: duplicate)

Opened 2 years ago

Last modified 2 years ago

$.getScript() equiv $.ajax() with timeout - timeout elapsed, error() fired, script still executed

Reported by: anonymous Owned by: anonymous
Priority: low Milestone: 1.next
Component: ajax Version: 1.5.2
Keywords: Cc:
Blocking: Blocked by:

Description

BUG: An $.ajax()-retrieved script is loaded/executed even after the ajax timeout is expired.

With $.ajax({dataType: 'script', type: 'GET', timeout: 10000}, success: ..., error: ...), the target script, if eventually retrieved, is executed even after the timeout has elapsed and the error handler has been executed. (That is long-hand code for $.getScript() with timeout and error handling added)

It should be easy enough to statically analyze for someone familiar with the $.ajax code. It is too difficult a situation to create a public test case for this because of the requirements, jsfiddle.net cannot handle it.

The usecase is to connect to a COMET server with $.getScript() which works well unless a timeout is specified (with the $.ajax({dataType: 'script'}) equivalent call) and the timeout is elapsed. In this case of the timeout elapsing, error() is run (as expected), firebug shows that the browser continues to wait for a result from the server, and once retrieved, jquery executes it without respect to the "timeout" or "abort" status.

I believe the fix needs to be in $.ajax's function done( status, statusText, responses, headers ) but I'm not familiar enough with this code to attempt the change.

COMET

A COMET server is a special webserver implementation which holds browser connections open until an event of interest to the client occurs, at which time a payload either of code or data can be returned to the browser. Code is preferred because it avoids the need for a parser on the client-side.

Change History

comment:1 Changed 2 years ago by anonymous

I assume that this happens with any content type, except that normally only the success callback is used to process it. With a dataType: 'script', it can run without being officially invoked by the user code.

comment:2 Changed 2 years ago by timmywil

  • Owner set to anonymous
  • Priority changed from undecided to low
  • Status changed from new to pending
  • Component changed from unfiled to ajax

Thanks for taking the time to contribute to the jQuery project! Do you perhaps have a running test case anywhere?

Also, please be sure you are testing against the git version of jQuery to ensure the issue still exists.

comment:3 Changed 2 years ago by jaubourg

  • Status changed from pending to closed
  • Resolution set to duplicate

This is a FF bug: when you remove a script tag from the document, the resource is still fetched.

comment:4 Changed 2 years ago by jaubourg

Duplicate of #8744.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.