Skip to content

Commit 0711a78

Browse files
author
Eric Prud'hommeaux
committed
~ preserve resolution result when clearing timeout
1 parent bdff7c9 commit 0711a78

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

test/flood-test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ describe('timeout-promise-queue', () => {
7373
function cb (done) {
7474
test.exec.then(exec => {
7575
if (test.ok) {
76-
report(true)
76+
if (typeof exec !== 'object' || exec.exitCode !== 0) {
77+
report(false, 'resolved result "' + JSON.stringify(exec) + '" !== { exitCode: 0 }')
78+
} else {
79+
report(true)
80+
}
7781
} else {
7882
report(false, 'unexpected success')
7983
}

timeout-promise-queue.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@ function PromiseQueue (threshold) {
3838
nextEntry()
3939
reject(r)
4040
}, timeout)
41-
myCancellation.on('clear', resolve)
41+
// pfunc().then emits 'clear' which resolves with pfunc's result.
42+
myCancellation.on('clear', result => resolve(result))
4243
return timer
4344
}),
4445
pfunc(clientCancellation).then(result => {
45-
myCancellation.emit('clear');
46+
myCancellation.emit('clear', result);
4647
clearTimeout(timer)
4748
return result
4849
})

0 commit comments

Comments
 (0)