Skip to content

sqlite: process aborts when an SQLite error message exceeds the V8 string limit #66520

Description

@trivikr

Version

main

Platform

All

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

sqliteIssues and PRs related to the SQLite subsystem.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions