Skip to content

Commit f499cbf

Browse files
authored
Revert advanced IPC
* Revert "Don't use global setImmediate" This reverts commit ea66e64. * Revert "Use advanced serialization (when available) for worker communication" This reverts commit 0f879f4.
1 parent 7694171 commit f499cbf

15 files changed

+41
-91
lines changed

lib/cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ exports.run = async () => { // eslint-disable-line complexity
430430
reporter.startRun(plan);
431431

432432
if (process.env.AVA_EMIT_RUN_STATUS_OVER_IPC === 'I\'ll find a payphone baby / Take some time to talk to you') {
433-
if (process.versions.node >= '12.17.0') {
433+
if (process.versions.node >= '12.16.0') {
434434
plan.status.on('stateChange', evt => {
435435
process.send(evt);
436436
});

lib/fork.js

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ const childProcess = require('child_process');
33
const path = require('path');
44
const fs = require('fs');
55
const Emittery = require('emittery');
6-
const {controlFlow} = require('./ipc-flow-control');
76

87
if (fs.realpathSync(__filename) !== __filename) {
98
console.warn('WARNING: `npm link ava` and the `--preserve-symlink` flag are incompatible. We have detected that AVA is linked via `npm link`, and that you are using either an early version of Node 6, or the `--preserve-symlink` flag. This breaks AVA. You should upgrade to Node 6.2.0+, avoid the `--preserve-symlink` flag, or avoid using `npm link ava`.');
@@ -15,12 +14,6 @@ const AVA_PATH = path.resolve(__dirname, '..');
1514

1615
const workerPath = require.resolve('./worker/subprocess');
1716

18-
const useAdvanced = process.versions.node >= '12.17.0';
19-
// FIXME: Fix this in api.js or cli.js.
20-
const serializeOptions = useAdvanced ?
21-
options => JSON.parse(JSON.stringify(options)) : // Use JSON serialization to remove non-clonable values.
22-
options => options;
23-
2417
module.exports = (file, options, execArgv = process.execArgv) => {
2518
let finished = false;
2619

@@ -41,8 +34,7 @@ module.exports = (file, options, execArgv = process.execArgv) => {
4134
cwd: options.projectDir,
4235
silent: true,
4336
env: {NODE_ENV: 'test', ...process.env, ...options.environmentVariables, AVA_PATH},
44-
execArgv,
45-
serialization: useAdvanced ? 'advanced' : 'json'
37+
execArgv
4638
});
4739

4840
subprocess.stdout.on('data', chunk => {
@@ -53,12 +45,12 @@ module.exports = (file, options, execArgv = process.execArgv) => {
5345
emitStateChange({type: 'worker-stderr', chunk});
5446
});
5547

56-
const bufferedSend = controlFlow(subprocess);
57-
5848
let forcedExit = false;
5949
const send = evt => {
60-
if (!finished && !forcedExit) {
61-
bufferedSend({ava: evt});
50+
if (subprocess.connected && !finished && !forcedExit) {
51+
subprocess.send({ava: evt}, () => {
52+
// Disregard errors.
53+
});
6254
}
6355
};
6456

@@ -74,7 +66,7 @@ module.exports = (file, options, execArgv = process.execArgv) => {
7466
}
7567

7668
if (message.ava.type === 'ready-for-options') {
77-
send({type: 'options', options: serializeOptions(options)});
69+
send({type: 'options', options});
7870
return;
7971
}
8072

lib/ipc-flow-control.js

Lines changed: 0 additions & 42 deletions
This file was deleted.

lib/worker/ipc.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22
const Emittery = require('emittery');
3-
const {controlFlow} = require('../ipc-flow-control');
43

54
const emitter = new Emittery();
65
process.on('message', message => {
@@ -26,9 +25,10 @@ process.on('message', message => {
2625
exports.options = emitter.once('options');
2726
exports.peerFailed = emitter.once('peerFailed');
2827

29-
const bufferedSend = controlFlow(process);
3028
function send(evt) {
31-
bufferedSend({ava: evt});
29+
if (process.connected) {
30+
process.send({ava: evt});
31+
}
3232
}
3333

3434
exports.send = send;

test-tap/fixture/report/regular/uncaught-exception.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const test = require('../../../..');
22

33
test('passes', t => {
4-
setImmediate(() => {
4+
setTimeout(() => {
55
throw new Error('Can’t catch me');
66
});
77
t.pass();

test-tap/reporters/mini.regular.v10.log

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,13 +515,13 @@
515515

516516
uncaught-exception.js:5
517517

518-
4: setImmediate(() => {
518+
4: setTimeout(() => {
519519
 5: throw new Error('Can’t catch me');
520520
6: });
521521

522522
Error: Can’t catch me
523523

524-
› Immediate.setImmediate (test-tap/fixture/report/regular/uncaught-exception.js:5:9)
524+
› Timeout.setTimeout (test-tap/fixture/report/regular/uncaught-exception.js:5:9)
525525

526526

527527

test-tap/reporters/mini.regular.v12.log

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -497,14 +497,15 @@
497497

498498
uncaught-exception.js:5
499499

500-
4: setImmediate(() => {
500+
4: setTimeout(() => {
501501
 5: throw new Error('Can’t catch me');
502502
6: });
503503

504504
Error: Can’t catch me
505505

506-
› Immediate.<anonymous> (test-tap/fixture/report/regular/uncaught-exception.js:5:9)
507-
› processImmediate (internal/timers.js:456:21)
506+
› Timeout._onTimeout (test-tap/fixture/report/regular/uncaught-exception.js:5:9)
507+
› listOnTimeout (internal/timers.js:549:17)
508+
› processTimers (internal/timers.js:492:7)
508509

509510

510511

test-tap/reporters/mini.regular.v14.log

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -497,14 +497,15 @@
497497

498498
uncaught-exception.js:5
499499

500-
4: setImmediate(() => {
500+
4: setTimeout(() => {
501501
 5: throw new Error('Can’t catch me');
502502
6: });
503503

504504
Error: Can’t catch me
505505

506-
› Immediate.<anonymous> (test-tap/fixture/report/regular/uncaught-exception.js:5:9)
507-
› processImmediate (internal/timers.js:458:21)
506+
› Timeout._onTimeout (test-tap/fixture/report/regular/uncaught-exception.js:5:9)
507+
› listOnTimeout (internal/timers.js:551:17)
508+
› processTimers (internal/timers.js:494:7)
508509

509510

510511

test-tap/reporters/tap.regular.v10.log

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,7 @@ not ok 25 - Error: Can’t catch me
323323
---
324324
name: Error
325325
message: Can’t catch me
326-
at: >-
327-
Immediate.setImmediate
328-
(test-tap/fixture/report/regular/uncaught-exception.js:5:9)
326+
at: 'Timeout.setTimeout (test-tap/fixture/report/regular/uncaught-exception.js:5:9)'
329327
...
330328
---tty-stream-chunk-separator
331329
# uncaught-exception.js exited with a non-zero exit code: 1

test-tap/reporters/tap.regular.v12.log

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,10 @@ not ok 25 - Error: Can’t catch me
296296
---
297297
name: Error
298298
message: Can’t catch me
299-
at: >-
300-
Immediate.<anonymous>
301-
(test-tap/fixture/report/regular/uncaught-exception.js:5:9)
302-
303-
processImmediate (internal/timers.js:456:21)
299+
at: |-
300+
Timeout._onTimeout (test-tap/fixture/report/regular/uncaught-exception.js:5:9)
301+
listOnTimeout (internal/timers.js:549:17)
302+
processTimers (internal/timers.js:492:7)
304303
...
305304
---tty-stream-chunk-separator
306305
# uncaught-exception.js exited with a non-zero exit code: 1

0 commit comments

Comments
 (0)