Opened 10 years ago
Closed 9 years ago
#12222 closed defect (invalid)
Error in one dojo.ready() or dojo.addOnLoad() will break all following calls
Reported by: | georgecalm | Owned by: | Rawld Gill |
---|---|---|---|
Priority: | low | Milestone: | 1.8 |
Component: | Core | Version: | 1.5 |
Keywords: | ready addOnLoad dojo.ready dojo.addOnLoad | Cc: | |
Blocked By: | Blocking: |
Description
Issue:
When an error is thrown inside one dojo.ready() [or dojo.addOnLoad()], the callback-functions in the following dojo.ready() will not be called.
Example:
dojo.ready(function(){console.log("one");}) one undefined dojo.ready(function(){console.log("two"); throw new Error("err"); }) two Error: err dojo.ready(function(){console.log("three");}) undefined
Note: "three" will never be written to the console.
Change History (5)
comment:1 Changed 10 years ago by
Owner: | anonymous deleted |
---|
comment:2 Changed 9 years ago by
comment:4 Changed 9 years ago by
Component: | General → Core |
---|---|
Owner: | set to Rawld Gill |
Status: | new → assigned |
comment:5 Changed 9 years ago by
Milestone: | tbd → 1.8 |
---|---|
Priority: | blocker → low |
Resolution: | → invalid |
Status: | assigned → closed |
We experimented with a version of dojo.ready that swallowed errors silently. This idea was rejected in [26408]. Indeed, it's probably irrational to muddle along after an error as if the error didn't happen.
Also, the soln is simple: if you've got a ready function that might throw and you don't care about throwing, then protect that function with a try-catch.
Lastly, dojo.ready can be nudged to start firing again after an error by adding another dojo.ready callback. Here is an example you can set async to either truthy or falsey...it works both ways.
<html> <head> <title>Nudge Dojo Ready After an Error</title> <script src="dojo/dojo.js" data-dojo-config="async:0"></script> <script> require(["dojo"], function(dojo){ dojo.ready(function(){console.log("one");}) dojo.ready(function(){console.log("two"); throw new Error("err"); }) dojo.ready(function(){console.log("three");}) require(["dojo/domReady"], function(){ setTimeout(function(){ console.log("nudging the ready machinery"); dojo.ready(function(){console.log("nudge complete")}); }, 200); }); }); </script> </head> <body> </body> </html>
this is a dup of a ticket I wrote and there was a long discussion on it... need to find this ticket...