Description
- Version: 14.1.0
- Platform: Windows 64-bit on VirtualBox and on Travis CI
- Subsystem: N/A
Bug description
After the Node.js 14.1.0 release, Babel's CI tests on Windows started failing. The failures are all related to @babel/cli
and @babel/node
: we run those CLI programs, capture their output (from stdout
) and compare it with the expected output.
Sometimes, the generated stdout
is empty: you can see an example here or here. In this CI log you can also see some error messages coming from V8 internals in @babel/node
tests, but I don't know if it's the same problem.
How often does it reproduce? Is there a required condition?
My guess is that every test has about 1% chance of failing. However, we have ~100 tests for those 2 packages so something is failing more often than not.
What steps will reproduce the bug?
I couldn't find a small and isolated reproduction example. I'll keep trying to create one, but here is what I have for now.
Also, building Babel on Windows is painful and I couldn't run the full test suite. However, I managed to reproduce the bug.
I'm running these commands using Powershell, Nodej.s 14.1.0 and Yarn 1.22
# Clone the babel repository
git clone https://github.com/babel/babel.git .
# Install deps
yarn
yarn lerna bootstrap # This takes a while
# Build Babel (this won't build everything, but enough packages to show the bug)
yarn gulp build-no-bundle
# Run the @babel/cli and @babel/node tests
yarn jest --runInBand babel-node babel-cli
If you don't see the last command failing, try running it 2 or three times. The --runInBand
option isn't necessary to reproduce the problem, but it disables Jest's workers so it removes one possible cause.
What is the expected behavior?
Tests should pass
What do you see instead?
An example of output failing locally is this:
PS C:\Users\Nicolò\Downloads\babel-master\babel-master> yarn jest --runInBand babel-node babel-cli
yarn run v1.22.4
$ C:\Users\Nicolò\Downloads\babel-master\babel-master\node_modules\.bin\jest --runInBand babel-node babel-cli
FAIL packages/babel-cli/test/index.js (33.099s)
● bin/babel › --only glob
"C:\Users\Nicolò\Downloads\babel-master\babel-master\packages\babel-cli\lib\babel" "--presets" "C:\Users\Nicolò\Downloads\babel-master\babel-master\packages\babel-preset-react" "--plugins" "C:\Users\Nicolò\Downloads\babel-master\babel-master\packages\babel-plugin-transform-arrow-functions,C:\Users\Nicolò\Downloads\babel-master\babel-master\packages\babel-plugin-transform-strict-mode,C:\Users\Nicolò\Downloads\babel-master\babel-master\packages\babel-plugin-transform-modules-commonjs" "src" "--out-dir" "lib" "--only" "**/*.foo.js" "--verbose": expect(received).toBe(expected) // Object.is equality
Expected: "src/a.foo.js -> lib/a.foo.js
src/baz/b.foo.js -> lib/baz/b.foo.js
Successfully compiled 2 files with Babel."
Received: ""
85 | expect(stdout).toContain(expectStdout);
86 | } else {
> 87 | expect(stdout).toBe(expectStdout);
| ^
88 | }
89 | } else if (stdout) {
90 | throw new Error("stdout:\n" + stdout);
at assertTest (packages/babel-cli/test/index.js:87:22)
at ChildProcess.<anonymous> (packages/babel-cli/test/index.js:152:9)
PASS packages/babel-node/test/index.js (22.924s)
Test Suites: 1 failed, 1 passed, 2 total
Tests: 1 failed, 89 passed, 90 total
Snapshots: 0 total
Time: 56.088s, estimated 62s
Ran all test suites matching /babel-node|babel-cli/i.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Additional information
-
You can see here how we capture
stdout
for@babel/cli
tests, . For@babel/node
it's the same. -
@JLHwung suggested that this might be related to stream: don't wait for close on legacy streams #33058 or stream: don't emit end after close #33076
-
The bug is not present when using Node.js 14.0