Skip to content

Fixing issue whereby user errors lead to response.header is not a function TypeError#167

Open
wjrm500 wants to merge 1 commit into
mainfrom
bugfix/response-header-is-not-a-function
Open

Fixing issue whereby user errors lead to response.header is not a function TypeError#167
wjrm500 wants to merge 1 commit into
mainfrom
bugfix/response-header-is-not-a-function

Conversation

@wjrm500
Copy link
Copy Markdown
Contributor

@wjrm500 wjrm500 commented Apr 7, 2025

Relates to Sentry error: https://funding-service-design-team-dl.sentry.io/issues/6471426578/?alert_rule_id=15706220&alert_type=issue&notification_uuid=08b61e1e-1e35-4fac-bad5-01612c95b829&project=4508573162864640&referrer=slack

The server crashes (TypeError: response.header is not a function) when onPreResponse tries modifying headers on non-5xx Boom error objects (e.g., 404s).

This PR changes onPreResponse in index.ts to bypass header modifications for all Boom errors (response.isBoom), preventing calls to the non-existent .header() function on those error objects (see docs). This aligns with the code in the base repo's index.ts which also bypasses header modifications in the case of Boom objects.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Apr 7, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant