express icon indicating copy to clipboard operation
express copied to clipboard

fix: prevent crash when BigInt passed to res.status()

Open theaniketgiri opened this issue 1 month ago • 2 comments

Fixes #6756

Previously, passing a BigInt to res.status() would cause an uncaught TypeError because JSON.stringify() cannot serialize BigInt values. The error occurred when trying to create the error message.

Changes:

  • Replace JSON.stringify(code) with template literal and typeof
  • Error message now shows both the value and its type
  • Add comprehensive tests for BigInt and other invalid types

theaniketgiri avatar Dec 03 '25 17:12 theaniketgiri

This is a duplicate of #6848, with the same approach.

krzysdz avatar Dec 04 '25 10:12 krzysdz

This is a duplicate of #6848, with the same approach.

Thanks for pointing out the Object.create(null) edge case!

I've updated this PR to handle it properly. The fix now uses:

  • Object.prototype.toString.call(code) for objects (handles null-prototype objects safely)
  • String(code) for primitives (handles BigInt correctly)

Added a test case specifically for Object.create(null) to verify the fix.

All 13 tests pass

theaniketgiri avatar Dec 04 '25 11:12 theaniketgiri

dashboard.html

pls sum one solve error 🙏🙏

vpn-game avatar Dec 11 '25 19:12 vpn-game

There's no crash here. Im sorry but misunderstanding the problem you're attempting to solve is a close from me.

jonchurch avatar Dec 12 '25 19:12 jonchurch