From 6a6a4bb9f95c546bc657b5f5d5ad546b3b144f0f Mon Sep 17 00:00:00 2001 From: Kyle Mathews Date: Thu, 15 Jul 2021 09:43:42 -0700 Subject: [PATCH] fix(gatsby): catch error from this.process.send (#32356) Co-authored-by: Ward Peeters (cherry picked from commit 99936a8cb24a0bafe4794e6ceffc864e6e103bc7) --- packages/gatsby/src/commands/develop.ts | 26 ++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/gatsby/src/commands/develop.ts b/packages/gatsby/src/commands/develop.ts index 3886de6b6a7af..7fc536a7fcf47 100644 --- a/packages/gatsby/src/commands/develop.ts +++ b/packages/gatsby/src/commands/develop.ts @@ -126,21 +126,21 @@ class ControllableScript { } this.isRunning = false - if (signal) { - try { + try { + if (signal) { this.process.kill(signal) - } catch (err) { - // Ignore error if process has crashed - // Ref: https://github.com/gatsbyjs/gatsby/issues/28011#issuecomment-877302917 + } else { + this.process.send({ + type: `COMMAND`, + action: { + type: `EXIT`, + payload: code, + }, + }) } - } else { - this.process.send({ - type: `COMMAND`, - action: { - type: `EXIT`, - payload: code, - }, - }) + } catch (err) { + // Ignore error if process has crashed or already quit. + // Ref: https://github.com/gatsbyjs/gatsby/issues/28011#issuecomment-877302917 } return new Promise(resolve => {