Version
main
Platform
Subsystem
sqlite
What steps will reproduce the bug?
import { Database } from 'node:sqlite';
import { constants } from 'node:buffer';
const db = new Database(':memory:');
// '\u20ac' is 1 UTF-16 unit but 3 UTF-8 bytes.
const name = '\u20ac'.repeat(Math.ceil(constants.MAX_STRING_LENGTH / 3) + 10);
try {
db.prepare(`SELECT 1 FROM "${name}"`);
} catch (err) {
console.log(err.code, err.message.length);
}
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
prepare() should throw a catchable error and not abort the process. With a 10-character name, the same code prints ERR_SQLITE_ERROR 25. ERR_SQLITE_ERROR is documented as "An error was returned from SQLite." If the message can't be represented as a JS string, the error should fall back to ERR_STRING_TOO_LONG or to an ERR_SQLITE_ERROR with a truncated message.
What do you see instead?
#
# Fatal error
# Check failed: String::kMaxLength >= len.
#
#
#
#FailureMessage Object: 0x16ce74ca8
----- Native stack trace -----
Additional information
No response
Version
main
Platform
Subsystem
sqlite
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
prepare()should throw a catchable error and not abort the process. With a 10-character name, the same code printsERR_SQLITE_ERROR 25.ERR_SQLITE_ERRORis documented as "An error was returned from SQLite." If the message can't be represented as a JS string, the error should fall back toERR_STRING_TOO_LONGor to anERR_SQLITE_ERRORwith a truncated message.What do you see instead?
Additional information
No response