Opened 7 years ago

Closed 5 years ago

Last modified 2 years ago

#16138 closed defect (wontfix)

dojo/request/script error function is not working

Reported by: dernafees Owned by: Bryan Forbes
Priority: low Milestone: 1.11
Component: IO Version: 1.8.0
Keywords: Cc:
Blocked By: Blocking:

Description

When trying the below code with any error such as http 404. the error function is not reached or executed.

require(["dojo/request/script"], function(script){
  script.get("something.js", {
    jsonp: "callback"
  }).then(function(data){
    // Do something with the response data
  }, function(err){
    // Handle the error condition
  });
  // Progress events are not supported
});

Change History (8)

comment:1 Changed 7 years ago by bill

Component: GeneralIO
Owner: set to Bryan Forbes

comment:2 Changed 6 years ago by Pete Smith

I see this exactly the same. I was expecting the dojo/request/notify to work the same as dojo/request but it does not, request.start works, but none of the other events for errors. request.load works as well.

Last edited 6 years ago by Pete Smith (previous) (diff)

comment:3 Changed 6 years ago by Pete Smith

Any progress on this? I bet it is really tough and maybe not possible.

comment:4 Changed 5 years ago by Bryan Forbes

Resolution: wontfix
Status: newclosed

dojo/request/script is implemented using script injection. There is no event triggered when a script element fails to load. As such, the error case in dojo/request/script cannot be triggered because of something like a 404. The recommended approach is to set a reasonable timeout parameter for your JSONP requests so that if it does 404, the timeout will eventually be reached and cause an error.

comment:5 Changed 4 years ago by Nick Nisi

I opened https://github.com/dojo/dojo/pull/140 to resolve this issue. Per http://www.w3.org/TR/html5/scripting-1.html#the-script-element, an 'error' event should be emitted on the script when there is an error, such as a 404 error. This does not occur in IE8, however, but when used with timeouts, it can help the request to fail faster.

comment:6 Changed 4 years ago by dylan

Milestone: tbd1.11
Priority: undecidedlow

comment:7 Changed 3 years ago by mssskhalsa

This is marked as "wontfix" and I only see it in master, not any older branches - is there no plan to backport this?

comment:8 Changed 2 years ago by dylan

It was not backported further as I don't believe it cleanly backported. Would consider a PR for older releases.

Note: See TracTickets for help on using tickets.