Skip to content

Conversation

@Ayoub-Mabrouk
Copy link
Contributor

Previously, when createError(NaN) was called, the status validation would fail to catch NaN because typeof NaN === 'number' is true in JavaScript. This resulted in errors with NaN status codes, which could cause issues in downstream code.

This fix adds an explicit isNaN() check to the status validation logic, ensuring that NaN status codes are properly caught and defaulted to 500.

Additionally, a test case has been added to verify this behavior and prevent regression.

Previously, when createError(NaN) was called, the status validation
would fail to catch NaN because typeof NaN === 'number' is true in
JavaScript. This resulted in errors with NaN status codes, which
could cause issues in downstream code.

This fix adds an explicit isNaN() check to the status validation
logic, ensuring that NaN status codes are properly caught and
defaulted to 500.

Additionally, a test case has been added to verify this behavior
and prevent regression.

Fixes: NaN status codes not being validated correctly
Copy link

@mbtools mbtools left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it 👍

@Ayoub-Mabrouk
Copy link
Contributor Author

I like it 👍

Thanks 😌

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.

2 participants