fix(Bun.SQL) fix postgres error handling when pipelining and state reset (#22505)

### What does this PR do?
Fixes: https://github.com/oven-sh/bun/issues/22395

### How did you verify your code works?
Test
This commit is contained in:
Ciro Spaciari
2025-09-08 21:00:39 -07:00
committed by GitHub
parent e63608fced
commit 1e4935cf3e
4 changed files with 227 additions and 152 deletions

View File

@@ -94,9 +94,10 @@ pub fn onWriteFail(
const vm = jsc.VirtualMachine.get();
const function = vm.rareData().postgresql_context.onQueryRejectFn.get().?;
const event_loop = vm.eventLoop();
const js_err = postgresErrorToJS(globalObject, null, err);
event_loop.runCallback(function, globalObject, thisValue, &.{
targetValue,
postgresErrorToJS(globalObject, null, err),
js_err.toError() orelse js_err,
queries_array,
});
}
@@ -116,7 +117,7 @@ pub fn onJSError(this: *@This(), err: jsc.JSValue, globalObject: *jsc.JSGlobalOb
const event_loop = vm.eventLoop();
event_loop.runCallback(function, globalObject, thisValue, &.{
targetValue,
err,
err.toError() orelse err,
});
}
pub fn onError(this: *@This(), err: PostgresSQLStatement.Error, globalObject: *jsc.JSGlobalObject) void {