Skip to content

Commit 620ddc0

Browse files
committed
Do not send close after readyForQuery
Close is used to release a named portal (which isn't used by pg-cursor) or when you're early-terminating a cursor on the unnamed portal. Sending 'close' on an connection which has already sent 'readyForQuery' results in the connection responding with a _second_ 'readyForQuery' which causes a lot of issues within node-postgres as 'readyForQuery' is the signal to indicate the client has gone back into the idle state.
1 parent 6072bce commit 620ddc0

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

index.js

+3
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ Cursor.prototype.end = function(cb) {
145145
}
146146

147147
Cursor.prototype.close = function(cb) {
148+
if (this.state == 'done') {
149+
return setImmediate(cb)
150+
}
148151
this.connection.close({type: 'P'})
149152
this.connection.sync()
150153
this.state = 'done'

0 commit comments

Comments
 (0)