3

I'm trying to debug some code that uses when.js. Stepping through code, at a certain point, I arrive in when.js itself, and then get buried in a long sequence of internal calls - promise fulfillments, queueing etc.

I have when.js blackboxed, but this doesn't seem to change much.

What I'd really like to do is skip forward to the next statement that is not in a blackboxed file, then immediately stop. Is there a way to achieve this?

In case there's doubt that the blackboxed script really does behave like this:

enter image description here

In my case, when.js is compiled into our app with browserify, and we have generated source maps.

Steve Bennett
  • 114,604
  • 39
  • 168
  • 219

1 Answers1

2

What I'd really like to do is skip forward to the next statement that is not in a blackboxed file, then immediately stop. Is there a way to achieve this?

That's exactly what framework blackboxing is designed for.

I believe the problem here is that when.js is compiled into you app and the debugger fails to recognize its code as blackboxed (despite the misleading warning). Let's say all source files of your application including when.js is compiled into app.js. In that case in the inspected page there is no such thing as when.js file hence JS execution will never be paused on a function from when.js (it will always be app.js). The source maps are applied on the UI level and once you paused somewhere in app.js we can map it to the corresponding location in when.js. All of that is performed too late in the DevTools UI though. What we have to do to support this is to be able to blackbox only part of app.js corresponding to compiled source of when.js. DevTools don't support this yet. I'd appreciate if you can file a feature request on this at crbug.com/new

Can you confirm that my understanding of the observed behavior is correct?

Yury Semikhatsky
  • 2,144
  • 13
  • 12
  • Thanks - that sounds right. But the strange thing is the "this script is blackboxed" message - clearly Chrome recognises that this code ultimately comes from when.js. Maybe a disconnect between UI and back end. Will file a feature request. Any workarounds in the meantime? – Steve Bennett Aug 24 '15 at 00:33
  • Ok it [has already been reported](https://code.google.com/p/chromium/issues/detail?id=341082&q=blackboxing%20browserify&colspec=ID%20Pri%20M%20Stars%20ReleaseBlock%20Cr%20Status%20Owner%20Summary%20OS%20Modified). Looks like there are no plans to support it, but apparently it works in FireFox. – Steve Bennett Aug 24 '15 at 00:37
  • The message you see is just a bug. We check on the front-end (UI) if the script URL matches blackboxed scripts to show the message and do it after source maps have been applied. On the other hand, as I said we check if script is blackboxed for pausing on the backend and do it without applying source maps. The only workaround I can think of at the moment is either use uncompiled sources for debugging (not sure if it is feasible) or have when.js compiled into a separate file. – Yury Semikhatsky Aug 24 '15 at 18:34
  • Ok, thanks very much. Not sure how feasible those things are for me (I didn't set up this build process) but maybe. – Steve Bennett Aug 25 '15 at 01:11