From 164eb9f8836eee7dbc85c6c37eae6033baf9775e Mon Sep 17 00:00:00 2001 From: Adam Nielsen Date: Fri, 2 Sep 2022 18:56:45 +1000 Subject: [PATCH] Possible fix for #2642 This isn't a real fix because it delves into the connection's private state, but it does illustrate one possible solution. --- packages/pg-cursor/index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/pg-cursor/index.js b/packages/pg-cursor/index.js index 9bbda641a..eaa1c66e4 100644 --- a/packages/pg-cursor/index.js +++ b/packages/pg-cursor/index.js @@ -217,6 +217,13 @@ class Cursor extends EventEmitter { } this._closePortal() + + if (this.connection._ending) { + // No point returning an error, we're finishing up either way. + cb() + return promise + } + this.connection.once('readyForQuery', function () { cb() })