Skip to content

Commit

Permalink
Handle rebuild failures without exiting
Browse files Browse the repository at this point in the history
When a rebuild fails, mark it as a builder failure so the watcher doesn't re-throw it, causing it to be an unhandled error that results in the process exiting.

Fixes #9584
  • Loading branch information
bendemboski authored and Kelly Selden committed Oct 4, 2022
1 parent 1376857 commit 4a36187
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/models/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ class Builder extends CoreObject {
} catch (error) {
await this.processAddonBuildSteps('buildError', error);

// Mark this as a builder error so the watcher knows it has been handled
// and won't re-throw it
error.isBuilderError = true;

throw error;
} finally {
clearInterval(uiProgressIntervalID);
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/models/builder-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,20 @@ describe('models/builder.js', function () {
await expect(builder.build()).to.be.rejected;
expect(hooksCalled).to.deep.equal(['preBuild', 'build', 'postBuild', 'outputReady', 'buildError']);
});

it('sets `isBuilderError` on handled addon errors', async function () {
addon.postBuild = function () {
return Promise.reject(new Error('preBuild Error'));
};

let error;
try {
await builder.build();
} catch (e) {
error = e;
}
expect(error).to.haveOwnProperty('isBuilderError', true);
});
});

describe('fallback from broccoli 2 to broccoli-builder', function () {
Expand Down

0 comments on commit 4a36187

Please sign in to comment.