From 8ef90df28c038651bc1bc33efaa8e1be9c2e45f5 Mon Sep 17 00:00:00 2001 From: Rafael Oleza Date: Tue, 17 Jul 2018 03:14:57 -0700 Subject: [PATCH] Clean metro server correctly after bundle errors Summary: This is a very similar fix than D8858846, but done in the RN CLI (soon we'll be able to just call `Metro.runBuild()` from RN which will remove this duplication). This actually fixes the issues in the integtration tests (t31612131). It's just funny that two unrelated problems that are caused by the same issue located in two different places have been reported at the same time. Differential Revision: D8859276 fbshipit-source-id: 805e111a406f2a7c1b3df3ab02accf4c4041a464 --- local-cli/bundle/buildBundle.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/local-cli/bundle/buildBundle.js b/local-cli/bundle/buildBundle.js index d1e422d4d0b..66d86462171 100644 --- a/local-cli/bundle/buildBundle.js +++ b/local-cli/bundle/buildBundle.js @@ -107,23 +107,23 @@ async function buildBundle( workerPath: config.getWorkerPath && config.getWorkerPath(), }); - const bundle = await output.build(server, requestOpts); + try { + const bundle = await output.build(server, requestOpts); - await output.save(bundle, args, log); + await output.save(bundle, args, log); - // Save the assets of the bundle - const outputAssets = await server.getAssets({ - ...Server.DEFAULT_BUNDLE_OPTIONS, - ...requestOpts, - bundleType: 'todo', - }); + // Save the assets of the bundle + const outputAssets = await server.getAssets({ + ...Server.DEFAULT_BUNDLE_OPTIONS, + ...requestOpts, + bundleType: 'todo', + }); - // When we're done saving bundle output and the assets, we're done. - const assets = await saveAssets(outputAssets, args.platform, args.assetsDest); - - server.end(); - - return assets; + // When we're done saving bundle output and the assets, we're done. + return await saveAssets(outputAssets, args.platform, args.assetsDest); + } finally { + server.end(); + } } module.exports = buildBundle;