Exit cleanly after flushing stdout

Summary:
Using `process.exit()` stops the node process without waiting for the event loop to finish, so when using async i/o, which is what happens when piped, if the output is buffered, the process can terminate before it finishes flushing the buffer.

This means you only get some of the output and the JSON is malformed.

This fixes it by calling `process.exit()` inside the flushed callback.

Reviewed By: passy

Differential Revision: D15624806

fbshipit-source-id: ea540ed5a40fb1811e5b705b190da96c8e54730d
This commit is contained in:
John Knox
2019-06-06 01:56:19 -07:00
committed by Facebook Github Bot
parent 873475405a
commit 92edb82e13
4 changed files with 38 additions and 15 deletions

View File

@@ -90,4 +90,5 @@ export default (store: Store, logger: Logger) => {
server.close();
});
}
return server.close;
};