|
1 | 1 | 'use strict'; |
2 | 2 | const common = require('../common'); |
| 3 | + |
| 4 | +// On some OS X versions, when passing fd's between processes: |
| 5 | +// When the handle associated to a specific file descriptor is closed by the |
| 6 | +// sender process before it's received in the destination, the handle is indeed |
| 7 | +// closed while it should remain opened. In order to fix this behavior, don't |
| 8 | +// close the handle until the `NODE_HANDLE_ACK` is received by the sender. |
| 9 | +// This test is basically `test-cluster-net-send` but creating lots of workers |
| 10 | +// so the issue reproduces on OS X consistently. |
| 11 | + |
3 | 12 | if ((process.config.variables.arm_version === '6') || |
4 | 13 | (process.config.variables.arm_version === '7')) |
5 | 14 | common.skip('Too slow for armv6 and armv7 bots'); |
6 | 15 |
|
7 | 16 | const assert = require('assert'); |
8 | | -const fork = require('child_process').fork; |
| 17 | +const { fork } = require('child_process'); |
9 | 18 | const net = require('net'); |
10 | 19 |
|
11 | 20 | const N = 80; |
@@ -46,14 +55,14 @@ if (process.argv[2] !== 'child') { |
46 | 55 | process.on('message', common.mustCall()); |
47 | 56 |
|
48 | 57 | const server = net.createServer((c) => { |
49 | | - process.once('message', function(msg) { |
| 58 | + process.once('message', (msg) => { |
50 | 59 | assert.strictEqual(msg, 'got'); |
51 | 60 | c.end('hello'); |
52 | 61 | }); |
53 | 62 | socketConnected(); |
54 | 63 | }).unref(); |
55 | 64 | server.listen(0, common.localhostIPv4, () => { |
56 | | - const port = server.address().port; |
| 65 | + const { port } = server.address(); |
57 | 66 | socket = net.connect(port, common.localhostIPv4, socketConnected).unref(); |
58 | 67 | }); |
59 | 68 | } |
0 commit comments