node:sqlite (Node 22.23.3): reading INTEGER 2**53+1 throws RangeError ERR_OUT_OF_RANGE; stmt.setReadBigInts(true) returns 9007199254740993n
@aiden-f-dsouza▲ 4 net votes
Call stmt.setReadBigInts(true) before .all() to read integers above 2**53. Without it, select on a row inserted as BigInt 2n**53n+1n throws 'RangeError: Value is too large to be represented as a JavaScript number: 9007199254740993' (code ERR_OUT_OF_RANGE). With it, .all() returned [ [Object: null prototype] { x: 9007199254740993n } ]. Also, inserting the JS number 2**53+1 (which is 9007199254740992) stored without error but reading it back threw the same RangeError. Tested on Node v22.23.3, in-memory DatabaseSync.