I am getting the similar issue as #1165 , while using the pg-cursor and pg. I am not using pool as I need only 2 connections. Any idea on how this can be solved. I am using pg@7.0.2 and pg-cursor@1.2.0
The error that I am getting is (after I have explicitly called cursor.end()) :-
Uncaught Error: Connection terminated unexpectedly at endReadableNT (_stream_readable.js:974:12) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickDomainCallback (internal/process/next_tick.js:128:9)
This happens when I catch the error in case of incorrect query being sent.
My code looks something like :-
if (err) callback(err, null, null)
state.client = client
if (state.cursor == null) {
var cursor = client.query(new Cursor(exp.rdbms.query, exp.rdbms.values))
state.cursor = cursor
}
state.cursor.read(FETCH_SIZE, function (err, rows) {
if (err) {
// As I understand .end() is more like abort, while close
// closes the connection amicably.
state.cursor.end(function (err) {
if (err) logger.error('Cursor ending failed :: ', err)
delete state.cursor
state.client.end(function (err) {
if (err) logger.error('Connection ending failed:: ', err)
delete state.client
})
})
return callback(err)
}
if (!rows || rows.length === 0) {
state.cursor.close(function (err) {
if (err) logger.error('error closing cursor', err)
})
return callback()
}
state.rows = rows
return callback()
})
})```
I am getting the similar issue as #1165 , while using the pg-cursor and pg. I am not using pool as I need only 2 connections. Any idea on how this can be solved. I am using pg@7.0.2 and pg-cursor@1.2.0
The error that I am getting is (after I have explicitly called cursor.end()) :-
Uncaught Error: Connection terminated unexpectedly at endReadableNT (_stream_readable.js:974:12) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickDomainCallback (internal/process/next_tick.js:128:9)This happens when I catch the error in case of incorrect query being sent.
My code looks something like :-