Search code examples
javascriptprofilingchromiumv8

Is there a way to detect in javascript if the Chrome/Chromium/V8 profiler is running?


My application has several costly debugging/development features that I would like to disable while the profiler is running.

I could run a prod build of the application but then I would lose useful function names.

My hope is that there is some sort of mechanism like checking if NODE_ENV is 'production'.


Solution

  • V8 developer here. I don't believe it is possible to detect whether the profiler is running. I think that's probably a good state of affairs -- it would potentially be very confusing if applications changed their behavior when you profile them. Even in your case where you're doing that intentionally (so you wouldn't be surprised), I guess it could easily lead to weird artifacts.

    I think that different build modes are probably the best solution. You could have a "development" build (full symbols and debugging features), a "profiling" mode (symbols only), and a "production" build (no symbols, no debugging features).