node/test/parallel/test-cluster-advanced-serialization.js

23 lines
555 B
JavaScript
Raw Normal View History

'use strict';
const common = require('../common');
const assert = require('assert');
const cluster = require('cluster');
if (cluster.isPrimary) {
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));
}