ava 3.12.0 → 3.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cli.js CHANGED
@@ -430,7 +430,7 @@ exports.run = async () => { // eslint-disable-line complexity
430
430
  reporter.startRun(plan);
431
431
 
432
432
  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') {
434
434
  plan.status.on('stateChange', evt => {
435
435
  process.send(evt);
436
436
  });
package/lib/fork.js CHANGED
@@ -3,7 +3,6 @@ const childProcess = require('child_process');
3
3
  const path = require('path');
4
4
  const fs = require('fs');
5
5
  const Emittery = require('emittery');
6
- const {controlFlow} = require('./ipc-flow-control');
7
6
 
8
7
  if (fs.realpathSync(__filename) !== __filename) {
9
8
  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, '..');
15
14
 
16
15
  const workerPath = require.resolve('./worker/subprocess');
17
16
 
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
-
24
17
  module.exports = (file, options, execArgv = process.execArgv) => {
25
18
  let finished = false;
26
19
 
@@ -41,8 +34,7 @@ module.exports = (file, options, execArgv = process.execArgv) => {
41
34
  cwd: options.projectDir,
42
35
  silent: true,
43
36
  env: {NODE_ENV: 'test', ...process.env, ...options.environmentVariables, AVA_PATH},
44
- execArgv,
45
- serialization: useAdvanced ? 'advanced' : 'json'
37
+ execArgv
46
38
  });
47
39
 
48
40
  subprocess.stdout.on('data', chunk => {
@@ -53,12 +45,12 @@ module.exports = (file, options, execArgv = process.execArgv) => {
53
45
  emitStateChange({type: 'worker-stderr', chunk});
54
46
  });
55
47
 
56
- const bufferedSend = controlFlow(subprocess);
57
-
58
48
  let forcedExit = false;
59
49
  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
+ });
62
54
  }
63
55
  };
64
56
 
@@ -74,7 +66,7 @@ module.exports = (file, options, execArgv = process.execArgv) => {
74
66
  }
75
67
 
76
68
  if (message.ava.type === 'ready-for-options') {
77
- send({type: 'options', options: serializeOptions(options)});
69
+ send({type: 'options', options});
78
70
  return;
79
71
  }
80
72
 
package/lib/worker/ipc.js CHANGED
@@ -1,6 +1,5 @@
1
1
  'use strict';
2
2
  const Emittery = require('emittery');
3
- const {controlFlow} = require('../ipc-flow-control');
4
3
 
5
4
  const emitter = new Emittery();
6
5
  process.on('message', message => {
@@ -26,9 +25,10 @@ process.on('message', message => {
26
25
  exports.options = emitter.once('options');
27
26
  exports.peerFailed = emitter.once('peerFailed');
28
27
 
29
- const bufferedSend = controlFlow(process);
30
28
  function send(evt) {
31
- bufferedSend({ava: evt});
29
+ if (process.connected) {
30
+ process.send({ava: evt});
31
+ }
32
32
  }
33
33
 
34
34
  exports.send = send;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ava",
3
- "version": "3.12.0",
3
+ "version": "3.12.1",
4
4
  "description": "Node.js test runner that lets you develop with confidence.",
5
5
  "license": "MIT",
6
6
  "repository": "avajs/ava",
@@ -1,42 +0,0 @@
1
- // Manage how quickly messages are delivered to the channel. In theory, we
2
- // should be able to call `send()` until it returns `false` but this leads to
3
- // crashes with advanced serialization, see
4
- // <https://github.com/nodejs/node/issues/34797>.
5
- //
6
- // Even if that's fixed (and the Node.js versions with the fixes are the
7
- // minimally supported versions) we need flow control based on `send()`'s return
8
- // value.
9
-
10
- const nowAndTimers = require('./now-and-timers');
11
-
12
- function controlFlow(channel) {
13
- let sending = false;
14
-
15
- const buffer = [];
16
- const deliverNext = () => {
17
- if (!channel.connected) {
18
- buffer.length = 0;
19
- }
20
-
21
- if (buffer.length === 0) {
22
- sending = false;
23
- return;
24
- }
25
-
26
- channel.send(buffer.shift(), deliverNext);
27
- };
28
-
29
- return message => {
30
- if (!channel.connected) {
31
- return;
32
- }
33
-
34
- buffer.push(message);
35
- if (!sending) {
36
- sending = true;
37
- nowAndTimers.setImmediate(deliverNext);
38
- }
39
- };
40
- }
41
-
42
- exports.controlFlow = controlFlow;