Skip to content

uncaught TypeError exception when using sendStatus with a BigNum #6756

@joshua-rogers-exodus

Description

@joshua-rogers-exodus

I know this is a stupid scenario, but I thought I'd report this bug because it probably is expected that it'll be caught:

// server.js
const express = require('express');
const app = express();

// Catch everything and return 200n
app.use((_req, res) => res.sendStatus(200n));

const port = process.env.PORT || 3000;
app.listen(port, () => console.log(`OK server on :${port}`));
$ node index.js & curl localhost:3000 &>/dev/null
[2] 4419
TypeError: Do not know how to serialize a BigInt
    at JSON.stringify (<anonymous>)
    at ServerResponse.status (/private/tmp/lol/node_modules/express/lib/response.js:65:54)
    at ServerResponse.sendStatus (/private/tmp/lol/node_modules/express/lib/response.js:329:8)
    at /private/tmp/lol/index.js:5:28
    at Layer.handleRequest (/private/tmp/lol/node_modules/router/lib/layer.js:152:17)
    at trimPrefix (/private/tmp/lol/node_modules/router/index.js:342:13)
    at /private/tmp/lol/node_modules/router/index.js:297:9
    at processParams (/private/tmp/lol/node_modules/router/index.js:582:12)
    at next (/private/tmp/lol/node_modules/router/index.js:291:5)
    at Function.handle (/private/tmp/lol/node_modules/router/index.js:186:3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions