dcodeIO / bcrypt.js

Optimized bcrypt in plain JavaScript with zero dependencies.
Other
3.47k stars 264 forks source link

process.nextTick still starves the event loop #80

Closed spion-h4 closed 6 years ago

spion-h4 commented 6 years ago

Hi! I noticed bcrypt.js uses process.nextTick in node to delay the calculation.

Unfortunately, repeated calls to nextTick will still starve the event loop: https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/#process-nexttick

nextTick is unfortunately badly named, it should've been called 'endOfThisTick`.

Can we switch to setImmediate instead?

spion-h4 commented 6 years ago

Never mind, I took a closer look the condition does pick setImmediate when its available. So this is not an issue in environments where thats present (although it might still be an issue in older node versions).