sqlite: isolate applyChangeset filter errors

Track filter callback failures within each applyChangeset() invocation.
Returning false from xFilter is not a SQLite error. This previously left
the database-wide suppression flag set, which could hide the next
unrelated SQLite error.

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: codex:gpt-5.6-sol
PR-URL: https://github.com/nodejs/node/pull/64823
Fixes: https://github.com/nodejs/node/issues/64822
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
This commit is contained in:
Kamat, Trivikram committed 2026-08-09 23:03:08 -07:00
1 parent d512d2dec9
commit ab95309457
2 files changed
+13 -5

No files matched your search

+6 -5
View File
@@ -2326,6 +2326,7 @@ void DatabaseSync::ApplyChangeset(const FunctionCallbackInfo<Value>& args) {
Local<Function> conflictFunc;
Local<Function> filterFunc;
bool filterCallbackFailed = false;
if (args.Length() > 1 && !args[1]->IsUndefined()) {
if (!args[1]->IsObject()) {
THROW_ERR_INVALID_ARG_TYPE(env->isolate(),
@@ -2387,25 +2388,25 @@ void DatabaseSync::ApplyChangeset(const FunctionCallbackInfo<Value>& args) {
filterFunc = filterValue.As<Function>();
context.filterCallback =
[env, db, &filterFunc](std::string_view item) -> bool {
context.filterCallback = [env, &filterFunc, &filterCallbackFailed](
std::string_view item) -> bool {
// If there was an error in the previous call to the filter's
// callback, we skip calling it again.
if (db->ignore_next_sqlite_error_) {
if (filterCallbackFailed) {
return false;
}
Local<Value> argv[1];
if (!ToV8Value(env->context(), item, env->isolate())
.ToLocal(&argv[0])) {
db->SetIgnoreNextSQLiteError(true);
filterCallbackFailed = true;
return false;
}
Local<Value> result;
if (!filterFunc->Call(env->context(), Null(env->isolate()), 1, argv)
.ToLocal(&result)) {
db->SetIgnoreNextSQLiteError(true);
filterCallbackFailed = true;
return false;
}