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
I found an issue with current implementation of user_code_runner. If I add a console.log statement to the timeout handlers then I can see that the timeouts are not cleared if the step was successful. This is not visible because cucumber bin uses process.exit to force the exit. But if someone use Cucumber programatically and try to shutdown gracefully the node process will not exit until all timeouts finish. That was my case in /~https://github.com/mucsi96/nightwatch-cucumber when I tried to add cucumber 2 support. It was really hard to find why my node process is not exiting :)
timeout was called will be logged on every step.
const timeoutPromise = new Promise(function (resolve, reject) {
clearTimeout = Time.setTimeout(function() {
console.log('timeout was called');
const timeoutMessage = 'function timed out after ' + timeoutInMilliseconds + ' milliseconds'
reject(new Error(timeoutMessage))
}, timeoutInMilliseconds)
})
racingPromises.push(timeoutPromise)
I wanted to submit a PR. But could not find a good way to test this :(
A solution whould be:
let timeoutId
const timeoutPromise = new Promise(function (resolve, reject) {
timeoutId = Time.setTimeout(function() {
const timeoutMessage = 'function timed out after ' + timeoutInMilliseconds + ' milliseconds'
reject(new Error(timeoutMessage))
}, timeoutInMilliseconds)
})
racingPromises.push(timeoutPromise)
let error, result
try {
result = await Promise.race(racingPromises)
timeoutId && Time.clearTimeout(timeoutId)
} catch (e) {
timeoutId && Time.clearTimeout(timeoutId)
if ((e instanceof Error)) {
error = e
} else if (e) {
error = util.format(e)
} else {
error = 'Promise rejected without a reason'
}
}
The text was updated successfully, but these errors were encountered:
mucsi96
changed the title
Timeout handlers is always called
Timeout handlers are always called
Dec 4, 2016
I found an issue with current implementation of
user_code_runner
. If I add aconsole.log
statement to the timeout handlers then I can see that the timeouts are not cleared if the step was successful. This is not visible because cucumber bin usesprocess.exit
to force the exit. But if someone use Cucumber programatically and try to shutdown gracefully the node process will not exit until all timeouts finish. That was my case in /~https://github.com/mucsi96/nightwatch-cucumber when I tried to add cucumber 2 support. It was really hard to find why my node process is not exiting :)timeout was called
will be logged on every step.I wanted to submit a PR. But could not find a good way to test this :(
A solution whould be:
The text was updated successfully, but these errors were encountered: