Reliable hang in Firefox tab during Karma test run

Hi Mozillans,

I am seeing a mostly reliable hang in a Firefox tab running some integration tests under Karma test runner. I am running Firefox 68.0.2 on Windows and Fedora Linux and seeing the hang in both places.

Can you give me tips on how to diagnose the cause so I can report this as a bug to Mozilla?

Thanks,
Dave Woldrich

I somehow managed to get the developer tools to break on the line that was hanging the tab!

In a postMessage handler callback on the window, I was popping objects off of an array in the closure’s parent scope and calling a function called “func” in those objects in a while loop. Maybe this is a JIT’ing problem?

The code that hangs looks like this:

while(messages.length) {
  try {
    messages.shift().func();
  } catch (e) {
    log.info(...)
  }
}

By removing the shift() and doing a for-loop over the array, I was able to avoid the hang. The line I was able to pause the browser on was the while(messages.length) line. The hang always occurred when there was a ton of DOM manipulation happening coincidentally with some of my integration tests.