Skip to content

sqlite: filter exception in applyChangeset() suppresses next SQLite error #64822

Description

@trivikr

Version

main

Platform

macOS 26.5.2

Subsystem

sqlite

What steps will reproduce the bug?

import { DatabaseSync } from 'node:sqlite';

const source = new DatabaseSync(':memory:');
const target = new DatabaseSync(':memory:');

source.exec('CREATE TABLE t (id INTEGER PRIMARY KEY)');
target.exec('CREATE TABLE t (id INTEGER PRIMARY KEY)');

const session = source.createSession();
source.exec('INSERT INTO t VALUES (1)');

try {
  target.applyChangeset(session.changeset(), {
    filter() {
      throw new Error('filter failed');
    },
  });
} catch (error) {
  console.log('applyChangeset:', error.message);
}

try {
  const result = target.exec('invalid SQL');
  console.log('invalid SQL:', result);
} catch (error) {
  console.log('invalid SQL threw:', error.message);
}

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

applyChangeset: filter failed
invalid SQL threw: near "invalid": syntax error

The callback-failure state is cleared when applyChangeset() returns, so the invalid SQL throws an SQLite syntax error.

What do you see instead?

applyChangeset: filter failed
invalid SQL: undefined

After catching the filter exception, unrelated invalid SQL silently returns undefined

Additional information

No response

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