Skip to content

Commit

Permalink
Don't crash on errors in logical streaming, but log and reconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
porsager committed Jun 2, 2023
1 parent 087c414 commit a4bf5fa
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/subscribe.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,15 @@ export default function Subscribe(postgres, options) {
}

stream.on('data', data)
stream.on('error', sql.close)
stream.on('error', error)
stream.on('close', sql.close)

return { stream, state: xs.state }

function error(e) {
console.error('Unexpected error during logical streaming - reconnecting', e)
}

function data(x) {
if (x[0] === 0x77)
parse(x.subarray(25), state, sql.options.parsers, handle, options.transform)
Expand Down

0 comments on commit a4bf5fa

Please sign in to comment.