Skip to content

Commit d7013dd

Browse files
fix: crash with --parallel and --retries both enabled (#5173)
* test case: crash with --parallel and --retries both enabled * fix: crash with --parallel and --retries both enabled
1 parent 5c2989f commit d7013dd

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

lib/nodejs/serializer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ class SerializableEvent {
259259
});
260260

261261
// mutates the object
262-
breakCircularDeps(result);
262+
breakCircularDeps(result.error);
263263

264264
const pairs = Object.keys(result).map(key => [result, key]);
265265

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import {it} from '../../../../index.js';
2+
3+
it('test', () => {
4+
throw new Error('Foo');
5+
});

test/integration/parallel.spec.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,19 @@ describe('parallel run', () => {
4343
assert.strictEqual(result.failures[0].err.message, 'Foo');
4444
assert.strictEqual(result.failures[0].err.foo.props[0], '[Circular]');
4545
});
46+
47+
it('should correctly handle an exception with retries', async () => {
48+
const result = await runMochaJSONAsync('parallel/circular-error.mjs', [
49+
'--parallel',
50+
'--jobs',
51+
'2',
52+
'--retries',
53+
'1',
54+
require.resolve('./fixtures/parallel/testworkerid1.mjs')
55+
]);
56+
assert.strictEqual(result.stats.failures, 1);
57+
assert.strictEqual(result.stats.passes, 1);
58+
assert.strictEqual(result.failures[0].err.message, 'Foo');
59+
assert.strictEqual(result.failures[0].err.foo.props[0], '[Circular]');
60+
});
4661
});

0 commit comments

Comments
 (0)