Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
fix(errorHandler): application errors would result in a 200 response (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
10xLaCroixDrinker authored Jan 23, 2024
1 parent badbd98 commit 26a7740
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions __tests__/server/ssrServer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,7 @@ describe('ssrServer', () => {
'"Fastify application error: method get, url "/example", correlationId "undefined", headersSent: false [Error: testing]"'
);
expect(renderStaticErrorPage).toHaveBeenCalledWith(request, reply);
expect(reply.code).toHaveBeenCalledWith(500);
});

test('setErrorHandler logs an error and renders the static error page with "headersSent" and "correlationId"', async () => {
Expand Down Expand Up @@ -709,6 +710,7 @@ describe('ssrServer', () => {
'"Fastify application error: method get, url "/example", correlationId "123", headersSent: true [Error: testing]"'
);
expect(renderStaticErrorPage).toHaveBeenCalledWith(request, reply);
expect(reply.code).toHaveBeenCalledWith(500);
});
});
});
1 change: 1 addition & 0 deletions src/server/ssrServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ async function appPlugin(fastify) {

request.log.error('Fastify application error: method %s, url "%s", correlationId "%s", headersSent: %s', method, url, correlationId, headersSent, error);

reply.code(500);
return renderStaticErrorPage(request, reply);
});
}
Expand Down

0 comments on commit 26a7740

Please sign in to comment.