
Description
Please consider improving subscribe error handling. Currently I can catch the initial rejection:
sql.subscribe('*', (row, {command, relation, key, old}) => {
console.log(command, relation.schema + '.' + relation.table, row, key, old);
}).catch(ex => {
console.log('SUBSCRIBE FAILED', ex);
});
But there's no way to catch failures happening later on or success if initial attempt fails, but later one succeeds. (promise is already settled) Promises are probably not the right interface here, when subscribe seems to be doing auto-recovery and connection retries under the hood. Something like EventEmitter or config object with user supplied onconnect/ondisconnect callbacks would be more useful. In any case subscribe generates periodical unhandled rejections for any subsequent retries after the first failure, which are not possible to handle from the app code.
Ideally, the app should be able to catch two events whenever they happen: when the connection is established and when it's lost. At that point the app can perform whatever is needed to handle potentially missed events in between.
BTW, being able to use user defined slots instead of ephemeral ones might be also a useful feature. That way it may be possible to not lose changes in between reconnects, too. ;)