Skip to content

fix: cast expires_utc to TEXT on Node < 24.4 to avoid BigInt overflow#5

Open
DhvanilPatel wants to merge 1 commit intosteipete:mainfrom
DhvanilPatel:fix/bigint-overflow-node22
Open

fix: cast expires_utc to TEXT on Node < 24.4 to avoid BigInt overflow#5
DhvanilPatel wants to merge 1 commit intosteipete:mainfrom
DhvanilPatel:fix/bigint-overflow-node22

Conversation

@DhvanilPatel
Copy link

Summary

  • Fixes cookie extraction failing on Node 22.x and 23.x with error: "Value is too large to be represented as a JavaScript number"
  • Adds workaround for expires_utc column which can exceed Number.MAX_SAFE_INTEGER

Problem

On Node < 24.4, node:sqlite doesn't have the readBigInts option and throws when encountering integers larger than Number.MAX_SAFE_INTEGER. Chrome stores expires_utc as WebKit microseconds (since 1601-01-01), which can exceed this limit for cookies with far-future expiration dates.

Example error:

node:sqlite failed reading Chrome cookies: Value is too large to be represented as a JavaScript number: 13443512747000000

Solution

When readBigInts is unavailable (Node < 24.4), cast expires_utc to TEXT in the SQL query:

SELECT ..., CAST(expires_utc AS TEXT) AS expires_utc, ...

The existing tryParseInt function already handles string values correctly, so no other changes are needed.

Test plan

  • All existing tests pass
  • Tested against real Chrome cookies database on Node 22.x
  • Verified with Oracle that cookie extraction now works without --browser-manual-login

Fixes #4

🤖 Generated with Claude Code

On Node < 24.4, `node:sqlite` throws when encountering integers larger
than Number.MAX_SAFE_INTEGER. Chrome stores `expires_utc` as WebKit
microseconds (since 1601-01-01), which can exceed this limit for
cookies with far-future expiration dates.

This commit adds a workaround that casts `expires_utc` to TEXT in the
SQL query when `readBigInts` is unavailable. The existing `tryParseInt`
function already handles string values, so no changes are needed
elsewhere.

Fixes cookie extraction failing with error:
"Value is too large to be represented as a JavaScript number: 13443512747000000"

🤖 Generated with [Claude Code](https://claude.ai/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

node:sqlite fails to read Chrome cookies on Node < 24.4 due to BigInt overflow

1 participant