Skip to content

Commit 8ea2f25

Browse files
antonbrianc
anton
authored andcommitted
bugfix: correctly create new connection for canceling copy to query
1 parent c5c3114 commit 8ea2f25

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/client.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ p.connect = function(callback) {
111111
con.on('copyOutResponse', function(msg) {
112112
if (self.activeQuery.stream === undefined) {
113113
self.activeQuery._canceledDueToError = new Error('No destination stream defined');
114-
(new self.constructor(self.config)).cancel(self, self.activeQuery);
114+
//canceling query requires creation of new connection
115+
//look for postgres frontend/backend protocol
116+
(new self.constructor({port: self.port, host: self.host})).cancel(self, self.activeQuery);
115117
}
116118
});
117119
con.on('copyData', function (msg) {

lib/native/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ var clientBuilder = function(config) {
203203
connection.on('copyOutResponse', function(msg) {
204204
if (connection._activeQuery.stream === undefined) {
205205
connection._activeQuery._canceledDueToError = new Error('No destination stream defined');
206-
(new clientBuilder(connection.config)).cancel(connection, connection._activeQuery);
206+
(new clientBuilder({port: connection.port, host: connection.host})).cancel(connection, connection._activeQuery);
207207
}
208208
});
209209
connection.on('copyData', function (chunk) {

0 commit comments

Comments
 (0)