-
-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Weird behaviour of verify() with setTimeout() #25
Comments
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 setTimeout(function () {}, 1e3)
console.time('Promise.resolve()')
Promise.resolve()
.then(function () {
console.timeEnd('Promise.resolve()')
})
// → Promise.resolve(): 4ms
console.time('setImmediate()')
new Promise(function (resolve) { setImmediate(resolve, 0)})
.then(function () {
console.timeEnd('setImmediate()')
})
// → setImmediate(): 7ms
console.time('setTimeout()')
new Promise(function (resolve) { setTimeout(resolve, 0)})
.then(function () {
console.timeEnd('setTimeout()')
})
// → setTimeout(): 7ms
console.time('process.nextTick()')
new Promise(function (resolve) { process.nextTick(resolve)})
.then(function () {
console.timeEnd('process.nextTick()')
})
// → process.nextTick(): 4ms |
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. |
Is there any news regarding this issue? If it's completely broken in C++, maybe you should create promises in the JS wrapper… |
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) |
I don't seem to be able to build the package from the git repo:
|
You don't have the submodule. Clone with |
My bad :) It works! Thanks for the fix. |
The promise returned by
verify()
does not resolve before the first timer is up.Steps to reproduce
Environment
Operating system: Debian Stretch
Node version: 4.3.0
The text was updated successfully, but these errors were encountered: