Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#18754 closed defect (invalid)

dojo/domReady executes multiple times under Chrome browsers (Dojo 1.8.5)

Reported by: adw99 Owned by:
Priority: undecided Milestone: tbd
Component: General Version: 1.8.5
Keywords: Cc:
Blocked By: Blocking:


  1. Load
  1. Open devTools, go to Sources for the page (inline JS) search for the string "var dojoChatLink = new DojoChatLink?" and put a breakpoint on this line.
  2. Reload the page
  3. When you hit the breakpoint, click the 'Resume' icon and wait a few seconds and then you will hit the breakpoint again, and again. (3-5 times depending on the version of Chrome you're using)

I've tested in Chrome 46 and 48 (Canary) and I see the code executed 3-5 times in different versions of Chrome. In FF 38.4 & IE 10 I see it execute once.

Change History (6)

comment:1 Changed 7 years ago by bill

Resolution: invalid
Status: newclosed

It's because that page itself keeps getting reloaded. Try setting a breakpoint on the line:

require(["dojo/domReady!"], function(){

You'll see the require() itself being executed multiple times.

Alternately you can check the network tab and see the page loading over and over again.

I don't know why the page keeps getting reloaded (although I'd be interested in hearing why if you figure it out). But anyway, it seems like this isn't a dojo bug, or at least, there's no evidence yet that it's a dojo bug.

Let us know though when you figure out what was causing the problem.

comment:2 Changed 7 years ago by adw99

Hi Bill, thank you for your time but I have to disagree. The next result of this condition is that I end up with multiple copies of the DojoChatLink? object being created and residing in browser memory. If the page was simply being reloaded then the browser should be reset after each reload. Now the wrinkle in that is the when the DojoChatLink? object is created it sets a timer that points back to itself, for the purpose of polling an API via Ajax. Is it possible that setting the timer causes the object to survive the reload of the page ?

comment:3 Changed 7 years ago by dylan

That page is so littered with dozens of anti-patterns, mixing old dojo.* code with newer code, with at least 5 separate require() blocks, each of which call an init() method.

This is really not a good example of how software should be engineered.

I don't think it's reasonable to send a 2000 line file and expect someone to try to track down this issue, as that's asking someone to perhaps spend hours looking into this. If you have an isolated test case that follows good engineering practices that shows this as reproducible, you're more likely to get help. Or you can explore paid commercial support options if you do not want to reduce your problem down to a reproducible test case. Thanks!

comment:4 Changed 7 years ago by adw99

Hi Dylan, thank you for your time. I would not expect you to debug the HTML/JS in question - it's the output of a legacy 'portal' system which combines HTML from multiple sources. I was hoping that someone from the Dojo team might be able to share some insight on the domReady plug-in and what, if anything, might cause it to be fired multiple times. Obviously this doesn't happen with a simple 'hello world' page or your unit tests would have caught it. Any suggestions you might have would be greatly appreciated. (Yes, I know, rewrite the entire application - it's in progress).

comment:5 Changed 7 years ago by bill

I don't think the top level page is being reloaded like when the user hits the reload button (or the F5 key). But all the <script> blocks on that page (i.e. javascript embedded in the page) are getting executed repeatedly, even the scripts that have nothing to do with dojo. I can't figure out why though, but it's probably something weird like for example you are running document.body.innerHTML = document.body.innerHTML.

comment:6 Changed 7 years ago by adw99

Hi Bill, thanks for the feedback. I do also have an issue open with the Chrome development team to approach the issue from their side. If I receive any insight or suggestions from their side I will pass them along for your consideration.

Note: See TracTickets for help on using tickets.