mirror of
https://github.com/nodejs/node.git
synced 2025-05-21 14:39:17 +00:00

Add an `serialization` option that allows child process IPC to use the (typically more powerful) V8 serialization API. Fixes: https://github.com/nodejs/node/issues/10965 PR-URL: https://github.com/nodejs/node/pull/30162 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
23 lines
554 B
JavaScript
23 lines
554 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const cluster = require('cluster');
|
|
|
|
if (cluster.isMaster) {
|
|
cluster.settings.serialization = 'advanced';
|
|
const worker = cluster.fork();
|
|
const circular = {};
|
|
circular.circular = circular;
|
|
|
|
worker.on('online', common.mustCall(() => {
|
|
worker.send(circular);
|
|
|
|
worker.on('message', common.mustCall((msg) => {
|
|
assert.deepStrictEqual(msg, circular);
|
|
worker.kill();
|
|
}));
|
|
}));
|
|
} else {
|
|
process.on('message', (msg) => process.send(msg));
|
|
}
|