javascript - setTimeout(number) cause breaking node.js REPL -
for example, when write in node.js repl in terminal:
settimeout(3);
it shows me error:
timers.js:110 first._ontimeout(); ^ typeerror: property '_ontimeout' of object [object object] not function @ timer.listontimeout [as ontimeout] (timers.js:110:15)
but, interesting breaks whole session (instead throwing error).
why happening?
thanks.
ps: know should add function first parameter. wanted know why breaks session.
when use settimeout
or setimmediate
, adds callback
to event queue since node can't guarantee callback fired in n
. since 3
isn't function fails fire, raises exception , exits before it's finished returning execution scope why kill repl.
now, that's different supplying callback , error occurring there since callback defined in execution scope of calling script. if callback throw error, raise exception in right scope. note node doesn't support string callback arg browsers do.
for such low timeout you're better off using process.nexttick(callback)
better perf , security you'll still see error raised @ top level.
Comments
Post a Comment