graphile / graphile/graphile-engine
pg-pubsub should subscribe to listeningClient.on('error')
- Dominant language
- JavaScript
- Stars
- 764
- Forks
- 128
- PR merge metrics
- No merged PRs in 30d
Description
### Summary
If the server disconnects us; we will only know when the next `select 1` runs:
https://github.com/graphile/graphile-engine/blob/9940895db5a35f218484620d610845201278611c/packages/pg-pubsub/src/index.ts#L181
We should catch this issue and reconnect earlier so we miss fewer events.
### Steps to reproduce
1. Set up a PostGraphile subscription.
2. Terminate the PostgreSQL backend handling this subscription.
### Expected results
pg-pubsub should reconnect quickly.
### Actual results
pg-pubsub only notices when the next `select 1` fails (up to 25 seconds later).
### Possible Solution
`client.on('error', () => {releaseClient(client); if (!pgPool.ending) setupClient()})`
Contributor guide
Assessment
This issue has not been assessed yet.