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
The promise returned by verify() does not resolve before the first timer is up.
Steps to reproduce
// Without this line, verify() takes about 50ms to complete, with it, it takes 1 second.setTimeout(function(){},1e3)console.time('verify()')require('argon2').verify('$argon2i$m=4096,t=3,p=1$tbagT6b1YH33niCo9lVzuA$htv/k+OqWk1V9zD9k5DOBi2kcfcZ6Xu3tWmwEPV3/nc','password').then(function(){console.timeEnd('verify()')})
It's not the first time I see this issue, which seems to be an issue with v8. Apparently, it happens the promise resolve/reject call happens on the next tick of the Node event loop, but setTimeout extends this tick until it the timeout is reached, and only then the event loop ticks.
There seems to be some workarounds for this but they are really weird and probably not worth the trouble. Care to share a real example where it is an issue?
I don't know where it comes from, this issue does not appear when using promises directly, neither combine with setImmediate()/setTimeout() or process.nextTick():
Activity
ranisalt commentedon Feb 25, 2016
It's not the first time I see this issue, which seems to be an issue with v8. Apparently, it happens the promise resolve/reject call happens on the next tick of the Node event loop, but setTimeout extends this tick until it the timeout is reached, and only then the event loop ticks.
There seems to be some workarounds for this but they are really weird and probably not worth the trouble. Care to share a real example where it is an issue?
ranisalt commentedon Feb 26, 2016
Marked as wontfix at least until there's a clarification on why this happens by v8.julien-f commentedon Feb 26, 2016
I don't know where it comes from, this issue does not appear when using promises directly, neither combine with
setImmediate()/setTimeout()orprocess.nextTick():This behavior currently breaks my tests.
ranisalt commentedon Feb 26, 2016
Oh, I see in your tests this is behavior for 0.9.x, I'll look at the changes from 0.8 and see what possible broken.
julien-f commentedon Apr 3, 2016
Is there any news regarding this issue?
If it's completely broken in C++, maybe you should create promises in the JS wrapper…
ranisalt commentedon Apr 7, 2016
Locally it worked properly, and I added a timeout test to prevent regression in the future. Could you check?
(sorry for the delay, life's a bit rushing)
julien-f commentedon Apr 7, 2016
I don't seem to be able to build the package from the git repo:
ranisalt commentedon Apr 7, 2016
You don't have the submodule. Clone with
--recursiveor rungit submodule update --init.julien-f commentedon Apr 7, 2016
My bad :)
Maybe it could be in the README ;)
It works! Thanks for the fix.