You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
There is an unusual stall between reqContinue and on('break') in node's debugger.
NOTE: this only occurs on node version 0.10.31 or above.
For example, given a program that is in a busy loop (with a break point inside the loop), I don't expect any delay between when I call continue and when my program hit the next break point. However, given such a program, when my program is paused (i.e. on break), if I wait x seconds to call continue, then it will take my program x seconds to hit the break point.
I'll clarify with a reduced case below:
Given the program below. All it does is busy loop.
varnodedebug=require('child_process').fork(__dirname+'/client.js',[process.pid,5858]);process.on('exit',function(){nodedebug.kill('SIGTERM');});// wait for debugger to attachsetInterval(function(){console.log('.');// this is line 8},100);
Now I write a client. This client will attach to the above busy loop program. Then, every n seconds, it will call continue, and measure how long it takes for the program to hit the next break point.
varrepl=require('repl');varbaseDebugger=require('_debugger');varclient=newbaseDebugger.Client();variteration=function(){timeout=Math.floor(Math.random()*10)*1000;// random timeout between 0-9svartime;client.once('break',function(){console.log("BREAK. waited "+(newDate().getTime()-time)/1000+'s')iteration();});setTimeout(function(){client.reqContinue(function(){console.log("REQCONTINUE after "+timeout/1000+'s')time=newDate().getTime()});},timeout)};client.once('ready',function(){client.setBreakpoint({type: 'scriptRegExp',target: '.*infiniteloop\.js',line: 8},function(){setTimeout(function(){iteration();},500)});});process._debugProcess(process.argv[2]);varhost='localhost';varport=5858;setTimeout(function(){// wait 1s for debugger port to openclient.connect(port,host);},1000)
I would expect such program to break almost immediately every time, but this is not the case:
Here's a sample output:
$ node ./infiniteloop.js
Hit SIGUSR1 - starting debugger agent.
debugger listening on port 5858
REQCONTINUE after 3s
.
BREAK. waited 0.007s // this is normal
REQCONTINUE after 2s
.
BREAK. waited 2.117s // waited 2s before breaking
REQCONTINUE after 5s
.
BREAK. waited 5.109s // waited 5s before breaking
REQCONTINUE after 5s
.
BREAK. waited 5.109s // waited 5s before breaking
REQCONTINUE after 9s
.
BREAK. waited 9.115s // waited 9s before breaking
This is the output in node version 0.10.30 and earlier, and is the output that I'm expecting:
$ node infiniteloop.js
Hit SIGUSR1 - starting debugger agent.
debugger listening on port 5858
REQCONTINUE after 2s
.
BREAK. waited 0.007s // no latency
REQCONTINUE after 8s
.
BREAK. waited 0.103s // no latency
REQCONTINUE after 8s
.
BREAK. waited 0.1s // no latency
REQCONTINUE after 2s
.
BREAK. waited 0.101s // no latency
REQCONTINUE after 4s
.
BREAK. waited 0.102s // no latency
The text was updated successfully, but these errors were encountered:
There is an unusual stall between reqContinue and on('break') in node's debugger.
NOTE: this only occurs on node version 0.10.31 or above.
For example, given a program that is in a busy loop (with a break point inside the loop), I don't expect any delay between when I call continue and when my program hit the next break point. However, given such a program, when my program is paused (i.e. on break), if I wait x seconds to call continue, then it will take my program x seconds to hit the break point.
I'll clarify with a reduced case below:
Given the program below. All it does is busy loop.
Now I write a client. This client will attach to the above busy loop program. Then, every n seconds, it will call continue, and measure how long it takes for the program to hit the next break point.
I would expect such program to break almost immediately every time, but this is not the case:
Here's a sample output:
This is the output in node version 0.10.30 and earlier, and is the output that I'm expecting:
The text was updated successfully, but these errors were encountered: