Skip to content

Commit ba052a3

Browse files
committed
fix(workers): use advanced serialization by default in child process workers
1 parent 0ab070c commit ba052a3

4 files changed

Lines changed: 6 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- `[jest-runtime, jest-transform]` share `cacheFS` between runtime and transformer ([#10901](https://github.com/facebook/jest/pull/10901))
2020
- `[jest-transform]` Pass config options defined in Jest's config to transformer's `process` and `getCacheKey` functions ([#10926](https://github.com/facebook/jest/pull/10926))
2121
- `[jest-worker]` Add support for custom task queues and adds a `PriorityQueue` implementation. ([#10921](https://github.com/facebook/jest/pull/10921))
22+
- `[jest-worker]` [**BREAKING**] Default to advanced serialization when using child process workers ([#10982] (https://github.com/facebook/jest/pull/10982))
2223

2324
### Fixes
2425

packages/jest-worker/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Maximum amount of times that a dead child can be re-spawned, per call. Defaults
6969

7070
#### `forkOptions: Object` (optional)
7171

72-
Allow customizing all options passed to `childProcess.fork`. By default, some values are set (`cwd`, `env` and `execArgv`), but you can override them and customize the rest. For a list of valid values, check [the Node documentation](https://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options).
72+
Allow customizing all options passed to `childProcess.fork`. By default, some values are set (`cwd`, `env`, `execArgv` and `serialization`), but you can override them and customize the rest. For a list of valid values, check [the Node documentation](https://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options).
7373

7474
#### `computeWorkerKey: (method: string, ...args: Array<any>) => ?string` (optional)
7575

packages/jest-worker/src/workers/ChildProcessWorker.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ export default class ChildProcessWorker implements WorkerInterface {
9292
} as NodeJS.ProcessEnv,
9393
// Suppress --debug / --inspect flags while preserving others (like --harmony).
9494
execArgv: process.execArgv.filter(v => !/^--(debug|inspect)/.test(v)),
95+
// default to advanced serialization in order to match worker threads
96+
// @ts-expect-error: option does not exist on the node 10 types
97+
serialization: 'advanced',
9598
silent: true,
9699
...this._options.forkOptions,
97100
});

packages/jest-worker/src/workers/__tests__/ChildProcessWorker.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ it('passes fork options down to child_process.fork, adding the defaults', () =>
7070
env: {...process.env, FORCE_COLOR: supportsColor.stdout ? '1' : undefined}, // Default option.
7171
execArgv: ['-p'], // Filtered option.
7272
execPath: 'hello', // Added option.
73+
serialization: 'advanced', // Default option.
7374
silent: true, // Default option.
7475
});
7576
});

0 commit comments

Comments
 (0)