• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common');
3const assert = require('assert');
4const child_process = require('child_process');
5
6// Regression test for https://github.com/nodejs/node/issues/34797
7const eightMB = 8 * 1024 * 1024;
8
9if (process.argv[2] === 'child') {
10  for (let i = 0; i < 4; i++) {
11    process.send(new Uint8Array(eightMB).fill(i));
12  }
13} else {
14  const child = child_process.spawn(process.execPath, [__filename, 'child'], {
15    stdio: ['inherit', 'inherit', 'inherit', 'ipc'],
16    serialization: 'advanced'
17  });
18  const received = [];
19  child.on('message', common.mustCall((chunk) => {
20    assert.deepStrictEqual(chunk, new Uint8Array(eightMB).fill(chunk[0]));
21
22    received.push(chunk[0]);
23    if (received.length === 4) {
24      assert.deepStrictEqual(received, [0, 1, 2, 3]);
25    }
26  }, 4));
27}
28