Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#7667 closed defect (fixed)

debugAtAllCosts + djConfig.require calls load functions too early

Reported by: dfabulich Owned by: James Burke
Priority: high Milestone: 1.2
Component: Core Version: 1.2beta
Keywords: Cc:
Blocked By: Blocking:


When you use djConfig.debugAtAllCosts together with djConfig.require, load functions configured with addOnLoad will be called before the djConfig.require modules have been loaded, resulting in JS errors on load.

In the attached example test, the index.html file is configured to require a module, "atallcosts.uberprovider", which in turn requires 9 other numbered modules: "atallcosts.provider1", "atallcosts.provider2", "atallcosts.provider3" and so on.

atallcosts.provider9 sets a variable"baz". The uberprovider sets a variable"bar". In the load function configured with addOnLoad, we write those two variables out into the page.

EXPECTED: The page should load without errors and contain the text "barbaz" ACTUAL: In Firefox 3.0.1, when djConfig.debugAtAllCosts = true, you'll get a JS error ("atallcosts.provider9 is undefined"). When djConfig.debugAtAllCosts = false, the test passes.

The attached test includes an embedded copy of dojo-1.1.1 core. I've also tested this against the dojo core trunk revision 15252; the bug is present there.

My user agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv: Gecko/2008070206 Firefox/3.0.1

PATCH INCLUDED: As far as I can tell, the problem here is that _xdDebugFileLoaded is calling _xdNotifyLoaded (which calls the load functions) when the debug queue reaches 0. Unfortunately, the debug queue reaches 0 before any djConfig.require modules are loaded.

To fix this, I've added code to loader_debug.js to explicitly watch out for in-flight modules, and to avoid calling _xdNotifyLoaded until there are no longer any in flight modules.

Attachments (2) (2.7 KB) - added by dfabulich 11 years ago.
atallcoststest.patch (733 bytes) - added by dfabulich 11 years ago.
patch for dojo/_base/_loader/loader_debug.js

Download all attachments as: .zip

Change History (7)

Changed 11 years ago by dfabulich

Attachment: added


Changed 11 years ago by dfabulich

Attachment: atallcoststest.patch added

patch for dojo/_base/_loader/loader_debug.js

comment:1 Changed 11 years ago by dfabulich

Unfortunately, with the 256K limit on attachment size, I can't upload a zip with an embedded copy of dojo.

To use the test, make dojo available in ./dojo (the index.html file includes ./dojo/dojo.js). I've tested it with 1.1.1 and trunk, as described above.

comment:2 Changed 11 years ago by bill

Owner: changed from anonymous to James Burke

James - the mozilla bug again?

Dfabulich - which browser(s)?

comment:3 Changed 11 years ago by bill

Milestone: tbd1.2

James is looking at this now.

comment:4 Changed 11 years ago by James Burke

Resolution: fixed
Status: newclosed

(In [15287]) Fixes #7667. Thanks for dfabulich for tracing down the problem and providing a patch to indicate what still needed to be checked. I did not use the patch as-is though: from what I can tell the extra setTimeout call to _xdDebugFileLoaded is not needed if we clear the currentResourceName before doing the check for inflight modules.

comment:5 Changed 11 years ago by James Burke

dfabulich: thanks for finding the issue and indicating how it should be fixed. However, I do not think the extra setTimeout call to _xdDebugFileLoaded is needed, so I did not put that in the fix.

Did you have that in there for a specific failure case? Feel free to leave a note here in the bug if I am missing something.

Note: See TracTickets for help on using tickets.