Commit d2a6a26
committed
fix: handle NaN status codes by defaulting to 500
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 correctly1 parent 61aee57 commit d2a6a26
2 files changed
+10
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
331 | 331 | | |
332 | 332 | | |
333 | 333 | | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
334 | 343 | | |
335 | 344 | | |
336 | 345 | | |
| |||
0 commit comments