Improve detection of task process exit (#10776)

Our build script waits for the `close` event to determine whether the
task has exited. The `exit` event is a better representation of this,
because if a stream is shared between multiple processes, the process
may exit without the `close` event being emitted.

We aren't sharing streams between processes, so this edge case doesn't
apply to us. This just seemed like a more suitable event to listen to,
since we care about the process exiting not the stream ending.

See this description of the `close` event from the Node.js
documentation [1]:

>The `'close'` event is emitted when the stdio streams of a child
>process have been closed. This is distinct from the `'exit'` event,
>since multiple processes might share the same stdio streams.

And see this description of the `exit` event:

>The `'exit'` event is emitted after the child process ends.

[1]: https://nodejs.org/docs/latest-v14.x/api/child_process.html#child_process_event_exit
feature/default_network_editable
Mark Stacey 4 years ago committed by GitHub
parent d5bfce3243
commit b124ac29fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      development/build/task.js

@ -83,7 +83,7 @@ function runInChildProcess(task) {
); );
// await end of process // await end of process
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
childProcess.once('close', (errCode) => { childProcess.once('exit', (errCode) => {
if (errCode !== 0) { if (errCode !== 0) {
reject( reject(
new Error( new Error(

Loading…
Cancel
Save