Skip to content

Commit a39e0d7

Browse files
author
Sandro Santilli
committed
Rework handling of missing stream object for copy ops
This version works better (doesn't throw) but also doesn't report any error, which is not good
1 parent de9d5e3 commit a39e0d7

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lib/query.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var Query = function(config, values, callback) {
1717
this.types = config.types;
1818
this.name = config.name;
1919
this.binary = config.binary;
20-
this.stream = config.stream;
20+
this.stream = config.stream;
2121
//use unique portal name each time
2222
this.portal = config.portal || ""
2323
this.callback = config.callback;
@@ -171,10 +171,17 @@ p.prepare = function(connection) {
171171
};
172172
p.streamData = function (connection) {
173173
if ( this.stream ) this.stream.startStreamingToConnection(connection);
174-
else this.handleError(new Error('No destination stream defined'));
174+
else {
175+
connection.endCopyFrom(); // send an EOF to connection
176+
// TODO: signal the problem somehow
177+
//this.handleError(new Error('No source stream defined'));
178+
}
175179
};
176180
p.handleCopyFromChunk = function (chunk) {
177181
if ( this.stream ) this.stream.handleChunk(chunk);
178-
else this.handleError(new Error('error', 'No source stream defined'));
182+
else {
183+
// TODO: signal the problem somehow
184+
//this.handleError(new Error('error', 'No destination stream defined'));
185+
}
179186
}
180187
module.exports = Query;

0 commit comments

Comments
 (0)