New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 628407 link

Starred by 3 users

Issue metadata

Status: Duplicate
Merged: issue 632245
Owner:
Last visit > 30 days ago
Closed: Jul 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug



Sign in to add a comment

Node --inspector should fire Runtime.executionContextFinished

Reported by noj...@gmail.com, Jul 14 2016

Issue description

UserAgent: Mozilla/5.0 (iPhone; CPU iPhone OS 9_2_1 like Mac OS X) AppleWebKit/601.1 (KHTML, like Gecko) CriOS/49.0.2623.73 Mobile/13D15 Safari/601.1.46

Steps to reproduce the problem:
Use case : automatically profile execution of a node script. 

E.g node-cpu-profile myscript.js arg1 arg2. 

this will basically run node --inspect-brk tsc.js, start profiling, wait for script to finish and dump the profile as [date].cpuprofile file which can be loaded in chrome devtools.

It will call Runtime.enable, Profiler.enable, profiler.start

It has no way of knowing when the script execution has finished. 

What is the expected behavior?
An event like Runtime.executionContextFinished will signal the client that all the script has finished executing and it can stop the profiler and other tools. 

This is only useful for node and doesn't make sense for a browser. 

What went wrong?
No event fired when script has finished executing. 

Did this work before? No 

Chrome version: <Copy from: 'about:version'>  Channel: n/a
OS Version: 
Flash Version:
 
Owner: dgozman@chromium.org
Status: Assigned (was: Unconfirmed)

Comment 2 Deleted

Cc: dgozman@chromium.org
Labels: -OS-Windows OS-All
Owner: eostroukhov@chromium.org
Sounds interesting. What if the script is waiting for IO? Listening to the socket? Scheduled a timer?

Do we only consider "the program has finished completely" usecase? I think node should destroy the context and issue Runtime.executionContextDestroyed in this case. It's just not wired up. Eugene, could you take a look please?

Comment 4 by noj...@gmail.com, Jul 15 2016

Just confirming, when Runtime.executionContextDestroyed is sent, I can still call Profiler.stop and get back the profile right ?

The idea is the client will auto stop when there is a executionContext[Finished|Destroyed] sent. Otherwise if user is waiting for IO, s?he can always press Ctrl+C at any time, when the action they want to record is over.

In node it be handled on process.on('SIGINT') which will stop profiler, dump the profile and exit the process.

The idea of cli utility is that developers can write performance regression tests and have continuous integration.
> Just confirming, when Runtime.executionContextDestroyed is sent, I can still call Profiler.stop and get back the profile right ?

This is where we should call V8Debugger::contextDestroyed:  https://github.com/nodejs/node/blob/master/src/node.cc#L2178. Probably makes sense to report it under node and fix it there.
(and yes, you'll be able to Profiler.stop it once you got the Runtime.executionContextDestroyed)

Comment 8 by noj...@gmail.com, Jul 28 2016

Could someone dupe this issue against https://bugs.chromium.org/p/chromium/issues/detail?id=632245

Didn't realize I had already created one a while ago.
Mergedinto: 632245
Status: Duplicate (was: Assigned)

Sign in to add a comment