Bug Tracker

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#13735 closed bug (notabug)

getScript() neither calls done nor fail on Bad Gateway

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

Description

When using getScript (as in:)

$.getScript(url)
.done(function(script, textStatus) {Logger.log(0, "loaded script:"+url);})
.fail(function(jqxhr, settings, exception) {Logger.log(1, "loading script failed! ("+url+") error:"+jqxhr.status+" exception:"+exception);
});

No function call will be made if the server answers with 502 (Bad Gateway)

Change History (5)

comment:1 Changed 6 years ago by jaubourg

Resolution: notabug
Status: newclosed

That's because cross-domain requests are not guaranteed to notify errors as documented here (see the error option).

We're doing the best we can using script tag injection under the hood.

comment:2 Changed 6 years ago by dev.coldice@…

Okay, I don't want to stress this too much, but the problem is a bit different: There is no Cross-Domain Problem (for the Browser), as it loads another script from the same server. When triggering a cross-domain denial, fail is called, giving a 404 (at least in my example), which is fine. The Problem is, that the server returns a 502 Bad Gateway Page, which is even caught in my debugging console, but the getScript function neither calls fail NOR done, where I would expect that at least one of them get's called.

comment:3 Changed 6 years ago by jaubourg

Then we need a minimal test case demonstrating the issue before we re-open this. I guess you cannot provide a jsfiddle or jsbin but could you have a page on one of your servers demonstrating the issue?

comment:4 Changed 6 years ago by dev.coldice@…

I have set up an example at http://devetopia.com/jtest/jquery_loadtest/test1.html

this test will try to load 3 js files - one from the same server, one from a different origin (which works) and one which gives bad gateway. Responses are logged in the middle box.

I'm quite surprised that the cross origin load works fine.

comment:5 Changed 6 years ago by jaubourg

So the failing script actually is cross-domain. Sometimes errors will be notified (like a 404), other times, however, the browser won't notify the error back up to the javascript (which is the case for the bad gateway).

There's nothing jQuery can do here.

Note: See TracTickets for help on using tickets.