Skip to content

Commit

Permalink
Better surfacing of server startup errors
Browse files Browse the repository at this point in the history
Output the error message coming from `create-servers`
  • Loading branch information
jpage-godaddy committed Nov 8, 2023
1 parent 00d5815 commit 6978dea
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
2 changes: 2 additions & 0 deletions packages/gasket-plugin-https/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# `@gasket/plugin-https`

- Better surfacing of server startup errors

### 6.34.4

- Upgrade eslint-plugin-unicorn v43 ([#436])
Expand Down
2 changes: 1 addition & 1 deletion packages/gasket-plugin-https/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ async function start(gasket) {
});
} else {
errorMessage = errs.create({
message: 'failed to start the http/https servers',
message: `Failed to start the web servers: ${errors.message}`,
serverOpts
});
}
Expand Down
20 changes: 15 additions & 5 deletions packages/gasket-plugin-https/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,16 +205,26 @@ describe('start hook', () => {
});

it('rejects with an Error on failure', async () => {
mockCreateServersModule.mockImplementation((_, fn) => fn(
errs.create({ https: { message: 'HTTP server failed to start', code: 'something' } })
));
mockCreateServersModule.mockImplementation((_, fn) => {
const httpsError = errs.create({
message: 'Cert file not found',
code: 'something'
});

fn(
errs.create({
message: httpsError.message,
https: httpsError
})
);
});

await start();

const expected = 'failed to start the http/https servers';
const expected = 'Failed to start the web servers: Cert file not found';
expect(gasketAPI.logger.error).toHaveBeenCalledWith(expected);
expect(mockDebugStub.mock.calls[0][0].message).toEqual(expected);
expect(mockDebugStub.mock.calls[0][1].https.message).toEqual('HTTP server failed to start');
expect(mockDebugStub.mock.calls[0][1].https.message).toEqual('Cert file not found');
});

it('rejects with an Error about ports on failure (with http)', async () => {
Expand Down

0 comments on commit 6978dea

Please sign in to comment.