Opened 11 years ago

Closed 10 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:



When an error is thrown inside one dojo.ready() [or dojo.addOnLoad()], the callback-functions in the following dojo.ready() will not be called.



dojo.ready(function(){console.log("two"); throw new Error("err"); })
Error: err


Note: "three" will never be written to the console.

Change History (5)

comment:1 Changed 11 years ago by Chris Mitchell

Owner: anonymous deleted

comment:2 Changed 11 years ago by Adam Peller

this is a dup of a ticket I wrote and there was a long discussion on it... need to find this ticket...

comment:3 Changed 10 years ago by Colin Snover

Priority: highblocker

Bulk update of open ticket priorities.

comment:4 Changed 10 years ago by bill

Component: GeneralCore
Owner: set to Rawld Gill
Status: newassigned

comment:5 Changed 10 years ago by Rawld Gill

Milestone: tbd1.8
Priority: blockerlow
Resolution: invalid
Status: assignedclosed

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 works both ways.

    <title>Nudge Dojo Ready After an Error</title>
	<script src="dojo/dojo.js" data-dojo-config="async:0"></script>
		require(["dojo"], function(dojo){
			dojo.ready(function(){console.log("two"); throw new Error("err"); })
			require(["dojo/domReady"], function(){
					console.log("nudging the ready machinery");
					dojo.ready(function(){console.log("nudge complete")});
				}, 200);
Note: See TracTickets for help on using tickets.