Ensures that the Metro server is closed when an exception happens in runBuild

Differential Revision: D6924180

fbshipit-source-id: 80f5bf60aa357ce8df0598e8fdac92776c4af601
This commit is contained in:
Maël Nison 2018-02-07 08:54:21 -08:00 committed by Facebook Github Bot
parent be528451f5
commit cbaf70ce99
1 changed files with 7 additions and 2 deletions

View File

@ -320,7 +320,13 @@ exports.runBuild = async (options: RunBuildOptions) => {
options.onBegin();
}
const metroBundle = await output.build(metroServer, requestOptions);
let metroBundle;
try {
metroBundle = await output.build(metroServer, requestOptions);
} finally {
await metroServer.end();
}
if (options.onComplete) {
options.onComplete();
@ -337,7 +343,6 @@ exports.runBuild = async (options: RunBuildOptions) => {
};
await output.save(metroBundle, outputOptions, console.log);
await metroServer.end();
return {metroServer, metroBundle};
};