graphile / graphile/graphile-engine

pg-pubsub should subscribe to listeningClient.on('error')

Open
#723 0 comments 0 reactions 0 assignees View on GitHub
bug
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.