Skip to content

fix(test-runner): make it compatible when running as a sub-process - #7298

Merged
Max Schmitt (mxschmitt) merged 1 commit into
microsoft:masterfrom
mxschmitt:bugfix/test-runner-make-sub-process-compatible
Jun 24, 2021
Merged

Max Schmitt (mxschmitt) merged 1 commit into
microsoft:masterfrom
mxschmitt:bugfix/test-runner-make-sub-process-compatible

Conversation

@mxschmitt

@mxschmitt Max Schmitt (mxschmitt) commented Jun 24, 2021 •

Copy link
Copy Markdown
Contributor

Works around the following bug: nodejs/node#12921

TL;DR process.exit() does kill the process right away and does not wait until the parent process has received the data.

I only received the JSON partly which was by that not parsable.

@mxschmitt
Max Schmitt (mxschmitt) force-pushed the bugfix/test-runner-make-sub-process-compatible branch from bda26ff to 6a96332 Compare June 24, 2021 14:09

@dgozman Dmitry Gozman (dgozman) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • We have _flushOutput method that should help in this case.
  • We cannot afford to not call process.exit() because there might be any random unfinished operations, e.g. setTimeout() called from describe or something like that.

Comment thread src/test/runner.ts
// See https://github.com/nodejs/node/issues/6456.
//
// We can use writableNeedDrain to workaround this, but it is only available
// since node v15.2.0.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Node.js 15+ is not relevant for us since we need to support Node.js 12+. The new fix also works in Node.js 12+.

@mxschmitt
Max Schmitt (mxschmitt) force-pushed the bugfix/test-runner-make-sub-process-compatible branch from da0ba11 to ecc4552 Compare June 24, 2021 22:18

@dgozman Dmitry Gozman (dgozman) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@mxschmitt
Max Schmitt (mxschmitt) merged commit 908ad69 into microsoft:master Jun 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants