Bug Tracker

Opened 6 years ago

Closed 6 years ago

#13665 closed bug (cantfix)

Concurrent jsonp requests with same callback fails persistently

Reported by: tom.gallard@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:

Description

Test case: http://jsfiddle.net/EkuuU/5/

The Jsonp ajax prefilter replaces the function to be called (in this case 'jsonpCallbackWithDelay' with its own function (line 8397 of jquery 1.9.1 ).

It then swaps the function back (line 8405) after the script has been downloaded and executed.

This causes a problem if there are two overlapping jsonp requests using the same callback function:

1.) Req 1 enters preFilter, and callback function is replaced by jquery function. Original function is stored in 'overwritten' variable. 2.) Req 2 enters preFilter and the callback function is replaced. However- as it has already been replaced in 1.), and not swapped back, the 'overwritten' variable ends up containing the jquery function rather than the original. 3.) Req 1 cleanup function (line 8405) is called, and tries to replace the original function. However as overwritten contains the wrong function, the original function is not replaced.

Change History (1)

comment:1 Changed 6 years ago by jaubourg

Resolution: cantfix
Status: newclosed

This is a known limitation of the jsonp implementation in jQuery. Getting around it implies a lot more trickeries than meets the eye and cannot be achieved without browser sniffing which is a no go in jQuery core. If you wanna have finer control over jsonp requests, use https://github.com/jaubourg/jquery-jsonp

Note: See TracTickets for help on using tickets.