Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to hide 3rd party JS function calls in stack trace in chrome or firebox debugger?

This is one of my pet issues w/ Chrome debugger. I have a function that calls 3rd-party library that internally calls 20 other functions and the 20th library function again calls another function in my library.

MyFunctionA()

-> calls libFunctionA()

-> calls libFunctionB()

...

-> calls libFunctionZ()

->calls MyFunctionB() {debugger;}

If I put a debugger in MyFunctionB, I see stack trace like below:

  1. MyFunctionB
  2. libFunctionZ
  3. libFunctionY
  4. libFunctionX
  5. ...
  6. ...
  7. MyFunctionA

I want to hide all the libFunctions(X,Y, Z etc..) so I can easily see only my libraries functions in the stack like below:

  1. MyFunctionB
  2. ..hidden library functions..
  3. MyFunctionA

Is there any way to do this in either Chrome or Firefox debuggers?

like image 498
Raja Rao Avatar asked Sep 01 '17 00:09

Raja Rao


People also ask

How do I find my call stack in Chrome?

View the Call Stack To view the call stack, open DevTools Sources panel and on the right panel, expand the Call Stack panel to see all the current functions in the call stack.

How can I see my call stack In Firefox?

Right-/Ctrl- clicking in the call stack pane opens a context menu with the following items: Restart frame restarts execution at the beginning of the current frame.

What does step over do in JavaScript?

# Step over line of code to execute the function without stepping into it. You're paused on A . By pressing Step over, DevTools executes all the code in the function that you're stepping over, which is B and C .


3 Answers

you can blacklist those scripts which you dont want to see.

steps:

  • Method 1:

    1. click on a file in the call stack, which you wish to blacklist.
    2. right click on source code of that and select "blacklist source"
  • Method 2: you can blackbox complete folder or files in settings > Blackboxing, using a pattern

enter image description here Next time: When paused on a breakpoint, in the call stack you will see a message stating the number of frames which are blackboxed. You can show these frames if you want, but since they are calls made from a blackboxed script they are hidden unless you click show.

like image 59
Shishir Arora Avatar answered Sep 20 '22 22:09

Shishir Arora


You can hide all the non-relevant stack trace lines in Chrome + Webpack by adding

webpack:///./node_modules

To the list of blacklisted source in Chrome Dev Tools Settings.

hide node_modules from stack traces

This is what the traces look like after:

enter image description here

Special thanks to other posters @Shishir Arora + @str

like image 20
Michael Yagudaev Avatar answered Sep 20 '22 22:09

Michael Yagudaev


Mozilla just announced that this feature was built into Firefox 58 Developer Edition. This most likely means that it also will be available in Firefox 58.

Similarly, the debugger can recognize two dozen common JavaScript libraries and group their stack frames in the call stack. This makes it easy to separate the code you wrote from code provided by a framework when you’re tracking down a bug:

Callstack with and without grouping

like image 40
str Avatar answered Sep 17 '22 22:09

str