Skip to content

Commit

Permalink
fix(api-runner-node): build should stop on error (#4347)
Browse files Browse the repository at this point in the history
* fix(api-runner-node): build should stop on error

If a plugin throws an error, the build should stop and exit with an error exit code, not just log the error and continue the build.

* style(api-runner-node): arrow fn must return value
  • Loading branch information
anjawaldbauer authored and KyleAMathews committed Mar 7, 2018
1 parent 2f8d815 commit ae75335
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/gatsby/src/utils/api-runner-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ module.exports = async (api, args = {}, pluginSource) =>
},
(err, results) => {
if (err) {
reporter.error(`${pluginName} returned an error`, err)
if (process.env.NODE_ENV === `production`) {
return reporter.panic(`${pluginName} returned an error`, err)
}
return reporter.error(`${pluginName} returned an error`, err)
}
// Remove runner instance
apisRunning = apisRunning.filter(runner => runner !== apiRunInstance)
Expand All @@ -181,7 +184,7 @@ module.exports = async (api, args = {}, pluginSource) =>
}

// Check if any of our waiters are done.
waitingForCasacadeToFinish = waitingForCasacadeToFinish.filter(
return waitingForCasacadeToFinish = waitingForCasacadeToFinish.filter(
instance => {
// If none of its trace IDs are running, it's done.
if (!_.some(apisRunning, a => a.traceId === instance.traceId)) {
Expand Down

0 comments on commit ae75335

Please sign in to comment.