Skip to content

Commit

Permalink
fix: crash with --parallel and --retries both enabled (#5173)
Browse files Browse the repository at this point in the history
* test case: crash with --parallel and --retries both enabled

* fix: crash with --parallel and --retries both enabled
  • Loading branch information
JoshuaKGoldberg authored Aug 6, 2024
1 parent 5c2989f commit d7013dd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/nodejs/serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ class SerializableEvent {
});

// mutates the object
breakCircularDeps(result);
breakCircularDeps(result.error);

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

Expand Down
5 changes: 5 additions & 0 deletions test/integration/fixtures/parallel/non-circular-error.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {it} from '../../../../index.js';

it('test', () => {
throw new Error('Foo');
});
15 changes: 15 additions & 0 deletions test/integration/parallel.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,19 @@ describe('parallel run', () => {
assert.strictEqual(result.failures[0].err.message, 'Foo');
assert.strictEqual(result.failures[0].err.foo.props[0], '[Circular]');
});

it('should correctly handle an exception with retries', async () => {
const result = await runMochaJSONAsync('parallel/circular-error.mjs', [
'--parallel',
'--jobs',
'2',
'--retries',
'1',
require.resolve('./fixtures/parallel/testworkerid1.mjs')
]);
assert.strictEqual(result.stats.failures, 1);
assert.strictEqual(result.stats.passes, 1);
assert.strictEqual(result.failures[0].err.message, 'Foo');
assert.strictEqual(result.failures[0].err.foo.props[0], '[Circular]');
});
});

0 comments on commit d7013dd

Please sign in to comment.