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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -