summaryrefslogtreecommitdiff
path: root/test/parallel/test-cluster-advanced-serialization.js
blob: ffca3a8f9727ca50e36902ecca8540b98fc26df4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
'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));
}