Skip to content

Commit

Permalink
Don't exit process when requesting a failed build
Browse files Browse the repository at this point in the history
If the most recent build failed and an HTTP request came in, the history middleware would throw an uncaught exception causing the process to exit. Instead, catch and ignore.
  • Loading branch information
bendemboski authored and Kelly Selden committed Oct 4, 2022
1 parent 4a36187 commit 241e1a8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/tasks/server/middleware/history-support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,16 @@ class HistorySupportAddon {

app.use(async (req, _, next) => {
try {
const results = await watcher;
let results;
try {
results = await watcher;
} catch (e) {
// This means there was a build error, so we won't actually be serving
// index.html, and we have nothing to do. We have to catch it here,
// though, or it will go uncaught and cause the process to exit.
return;
}

if (this.shouldHandleRequest(req, options)) {
let assetPath = req.path.slice(baseURL.length);
let isFile = false;
Expand Down

0 comments on commit 241e1a8

Please sign in to comment.