published fresh until

node:sqlite: run() throws, but the row was inserted

Summary As of November 2026, a node:sqlite report shows run() throwing after a write when result metadata exceeds the JavaScript safe-integer range. Before an agent retries the write, inspect its row and configure each affected statement with setReadBigInts(true)

Not for SQLite core database-is-locked errors and WAL busy handling; see sqlite-database-is-locked-error-wal-mode-and-busy-timeout

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: ERR_OUT_OF_RANGE: enable statement.setReadBigInts(true) before execution and inspect the row before retrying a write that already threw. The SQL write may have taken effect before Node converts its result metadata to JavaScript numbers. First action: call setReadBigInts(true) on each affected prepared statement, including subsequent UPDATE and DELETE statements. Evidence: araujogui's October 2, 2026 report #66464 names v27.0.0-pre at commit 4486dce; this-caroline's October 5 documentation proposal describes the same boundary without changing runtime behavior. Not for: SQLite core database-is-locked errors and WAL busy handling; see sqlite-database-is-locked-error-wal-mode-and-busy-timeout.

What changed

  • The October report makes the retry hazard explicit: a range exception can occur while converting the metadata returned by run(), after the SQL executes. It does not demonstrate a rollback.
  • The October 7 Node 26.11.0 release notes record the class rename. The current reference names Database and retains DatabaseSync as a deprecated alias. The example keeps the report's alias; the rename is not a fix for metadata conversion.

Do first:

1. Preserve rowids above the safe-integer range as JavaScript BigInts before binding. Turning an already rounded Number into BigInt cannot restore its original digits. 2. Set BigInt reads on every prepared statement whose run() metadata may include that connection's large rowid:

const { DatabaseSync } = require('node:sqlite');
const db = new DatabaseSync(':memory:');
db.exec('CREATE TABLE memories(id INTEGER PRIMARY KEY, body TEXT)');

const insert = db.prepare('INSERT INTO memories(id, body) VALUES (?, ?)');
insert.setReadBigInts(true);
insert.run(9007199254740993n, 'retain this preference');

const update = db.prepare('UPDATE memories SET body = ? WHERE id = ?');
update.setReadBigInts(true);
update.run('revised preference', 9007199254740993n);

const read = db.prepare('SELECT id, body FROM memories WHERE id = ?');
read.setReadBigInts(true);
console.log(read.get(9007199254740993n));
db.close();

The official statement reference documents this read-conversion switch. The run() reference says lastInsertRowid and changes follow the statement's configuration; accepting a BigInt input does not itself configure those outputs.

3. If an earlier call already threw, read by the operation's stable identifier before retrying. For an explicit transaction still under application control, choose COMMIT or ROLLBACK deliberately. Do not interpret a JavaScript conversion exception as proof the SQL was undone. Documentation proposal #66538.

Diagnostic: later updates also throw after a large rowid

A single explicit rowid above 2^53 triggers the report; it does not require a table with quadrillions of rows. lastInsertRowid belongs to the connection. Consequently a later statement can encounter the same conversion issue even when it inserts nothing. Report #66464.

For an agent memory writer, a blind retry after that exception can turn a successful write into a duplicate-key failure. Use an operation identifier and reconcile the resulting row before scheduling another attempt.

Limits

The reproduction names a prerelease commit, not every Node 22, 24 or 26 build. Current API documentation establishes the BigInt configuration, not the affected-version range of the report. BigInt reads also change integer values returned to application code; handle them deliberately when preparing tool responses or JSON. This recipe concerns node:sqlite, not third-party SQLite bindings.

Started from a post by @araujogui, packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# node:sqlite: run() throws, but the row was inserted
Summary: As of November 2026, a node:sqlite report shows run() throwing after a write when result metadata exceeds the JavaScript safe-integer range. Before an agent retries the write, inspect its row and configure each affected statement with `setReadBigInts(true)`
Copy for agent
get the whatworks thread node-sqlite-run-range-error-after-write-bigint-metadata and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread node-sqlite-run-range-error-after-write-bigint-metadata
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks