Skip to content

Commit 37ea3bd

Browse files
authored
Merge pull request #174 from yandex/fix/173-unhandled-rejections-q
Unhandled rejections should not force the subprocess to exit
2 parents b2d8f48 + cf3aaa7 commit 37ea3bd

File tree

7 files changed

+38
-3
lines changed

7 files changed

+38
-3
lines changed

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
"mocha-teamcity-reporter": "^2.4.0",
8282
"mochawesome": "^3.0.2",
8383
"node-gyp": "^3.6.0",
84+
"q": "^1.5.1",
8485
"sinon": "^6.0.0",
8586
"ts-node": "^7.0.0",
8687
"tslint": "^5.10.0",

src/subprocess/runner.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,10 @@ import {
2222
applyRequires,
2323
applyTimeouts,
2424
randomId,
25-
setProcessExitListeners,
2625
} from '../util';
2726

2827
import applyExit from './options/exit';
2928

30-
setProcessExitListeners();
31-
3229
const argv = yargs
3330
.boolean('bail')
3431
.option('compilers', {

test/index.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ echo $?
152152
echo 'TESTCASE: subprocess exits before sending an end message'
153153
test test/no-subprocess-end/index.js
154154
echo $?
155+
echo 'TESTCASE: unhandled rejections should not force subprocess to exit'
156+
test test/q-promises/index.js
157+
echo $?
155158

156159
echo "Passes: $PASSES Failes: $FAILES"
157160

test/q-promises/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Make sure that q-based promises do not force subprocess to exit

test/q-promises/index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env node
2+
3+
const assert = require('assert');
4+
const sinon = require('sinon');
5+
6+
const MochaParallelTests = require('../../dist/main/mocha').default;
7+
const { setProcessExitListeners } = require('../../dist/util');
8+
const SilentReporter = require('../util/silent-reporter');
9+
10+
setProcessExitListeners();
11+
12+
const onRunnerEnd = sinon.fake();
13+
const mocha = new MochaParallelTests;
14+
mocha.reporter(SilentReporter);
15+
mocha.addFile(`${__dirname}/index.spec.js`);
16+
mocha.run().on('end', onRunnerEnd);
17+
18+
process.on('exit', () => {
19+
assert.strictEqual(onRunnerEnd.callCount, 1, `runner "end" event occured wrong number of times: ${onRunnerEnd.callCount}`);
20+
});

test/q-promises/index.spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const { reject } = require('q');
2+
3+
describe('suite', function () {
4+
it('case', function () {
5+
reject(new Error('foo'));
6+
});
7+
});

0 commit comments

Comments
 (0)