Skip to content

Commit a4bf5fa

Browse files
committed
Don't crash on errors in logical streaming, but log and reconnect
1 parent 087c414 commit a4bf5fa

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/subscribe.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,15 @@ export default function Subscribe(postgres, options) {
9797
}
9898

9999
stream.on('data', data)
100-
stream.on('error', sql.close)
100+
stream.on('error', error)
101101
stream.on('close', sql.close)
102102

103103
return { stream, state: xs.state }
104104

105+
function error(e) {
106+
console.error('Unexpected error during logical streaming - reconnecting', e)
107+
}
108+
105109
function data(x) {
106110
if (x[0] === 0x77)
107111
parse(x.subarray(25), state, sql.options.parsers, handle, options.transform)

0 commit comments

Comments
 (0)