Skip to content
This repository was archived by the owner on Nov 21, 2025. It is now read-only.

Commit e79407e

Browse files
authored
fix(pg): Return patched promise instead of original (#1470)
This ensures that asynchronous work done by patching gets awaited properly. In particular, it prevents unhandled promise rejections. Fixes #1319.
1 parent ed422ed commit e79407e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/plugins/plugin-pg.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class PostgresPatchUtility {
159159
promise: Promise<pg_7.QueryResult>,
160160
span: Span
161161
): Promise<pg_7.QueryResult> {
162-
return (promise = promise.then(
162+
return promise.then(
163163
res => {
164164
this.maybePopulateLabelsFromOutputs(span, null, res);
165165
span.endSpan();
@@ -170,7 +170,7 @@ class PostgresPatchUtility {
170170
span.endSpan();
171171
throw err;
172172
}
173-
));
173+
);
174174
}
175175
}
176176

@@ -288,7 +288,7 @@ const plugin: Plugin = [
288288
// Unlike in pg 6, the returned value can't be both a Promise and
289289
// a Submittable. So we don't run the risk of double-patching
290290
// here.
291-
pgPatch.patchPromise(pgQuery, span);
291+
pgQuery = pgPatch.patchPromise(pgQuery, span);
292292
}
293293
}
294294
return pgQuery;

0 commit comments

Comments
 (0)