Repository navigation
🐛 Bug: Unable to terminate long running tests #3570
Description
Activity
- addedstatus: waiting for authorwaiting on response from OP or other posters - more information neededwaiting on response from OP or other posters - more information neededarea: node.jscommand-line-or-Node.js-specificcommand-line-or-Node.js-specific
on Nov 14, 2018 @plroebuck Please run it with
time:time ./node_modules/mocha/bin/_mocha --timeout 10000000 test.js ; echo $? ^C ✓ should run 10 seconds (10010ms) 1 passing (10s) real 0m10.107s user 0m0.084s sys 0m0.020s 130The problem is that the test is terminated after 10 seconds, not right after Ctrl+C pressed.
Looks like it's caused byLines 645 to 652 in a371e2f
process.on('SIGINT', () => { runner.abort(); // This is a hack: // Instead of `process.exit(130)`, set runner.failures to 130 (exit code for SIGINT) // The amount of failures will be emitted as error code later runner.failures = 130; }); That portion of code only handles setting the exit code for
SIGINT(aka <Ctrl-C>).$ time bin/_mocha --timeout 1000000 /tmp/test.js; echo $? ^C real 0m1.989s user 0m0.116s sys 0m0.042s 130 $
@plroebuck How can I checkout your mocha version?
$ git checkout cfb1182c172e43effa3011f4ab620e4935f621e9 fatal: reference is not a tree: cfb1182c172e43effa3011f4ab620e4935f621e9Same issue on Mac for me
$ sw_vers ProductName: Mac OS X ProductVersion: 10.14.1 BuildVersion: 18B75 $ node --version v10.13.0 $ ./node_modules/mocha/bin/_mocha --version 5.2.0 $ time ./node_modules/mocha/bin/_mocha --timeout 1000000 /tmp/test.js ; echo $? ^C^C^C ✓ should run 10 seconds (10005ms) 1 passing (10s) real 0m10.151s user 0m0.122s sys 0m0.025s 130Could you please try to repro using mocha 5.2.0 from npm?
In my local with d60b333 , I can reproduce it.
time bin/_mocha --timeout 1000000 test.js ; echo $? ^C ✓ should run 10 seconds (10004ms) 1 passing (10s) real 0m10.199s user 0m0.178s sys 0m0.036s 130time bin/mocha --timeout 1000000 test.js ; echo $? hfoehfoe ^CTerminated: 15 real 0m0.606s user 0m0.228s sys 0m0.050s 143$ sw_vers ProductName: Mac OS X ProductVersion: 10.14.1 BuildVersion: 18B75 $ node -v v10.11.0 $ ./bin/mocha --version 5.2.0@outsideris Thanks for confirming. Right,
bin/_mochashould be used, notbin/mocha, I wasn't clear enough about it in the description.Guys, any idea on ideal SIGINT handling? Maybe something like: on the first SIGINT received, keep the current behavior, and if test is still running after N seconds (say N=2), disable SIGINT handler and resend SIGINT?
- addedtype: buga defect, confirmed by a maintainera defect, confirmed by a maintainerstatus: accepting prsMocha can use your help with this one!Mocha can use your help with this one!area: usabilityconcerning user experience or interfaceconcerning user experience or interfaceand removedstatus: waiting for authorwaiting on response from OP or other posters - more information neededwaiting on response from OP or other posters - more information needed
on Dec 5, 2018 30 remaining items
- added a commit that references this issue
on Apr 8, 2019 - added a commit that references this issue
on Sep 12, 2019 - changed the title
[-]Unable to terminate long running tests[/-][+]🐛 Bug: Unable to terminate long running tests[/+]on Dec 27, 2023 I don't reproduce this - so looks like #3556 did fix it! Yay! 🎉
If anybody is still seeing this bug, please do file a new issue with one of our new issue templates. They'll prompt for the info we'd need to re-triage. Cheers all! 🤎
Prerequisites
faqlabelnode node_modules/.bin/mocha --version(Local) andmocha --version(Global). We recommend avoiding the use of globally installed Mocha.Description
Unable to terminate tests manually, e.g via Ctrl+C when running tests in a terminal.
Steps to Reproduce
mocha --timeout 1000000 test.jsExpected behavior: The test is terminated.
Actual behavior: The test is still running.
Reproduces how often: Always
Versions
mocha --versionandnode node_modules/.bin/mocha --version: 5.2.0 and 5.2.0node --version: v10.13.0Additional Information