Skip to content

Commit 6a08635

Browse files
authored
Add docs about adding error handlers (#531)
2 parents 530ca17 + b7522ed commit 6a08635

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

website/docs/library/queue.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,27 @@ singleton throughout your code.
8080
- `schema` can be used to change the default `graphile_worker` schema to
8181
something else (equivalent to `--schema` on the CLI)
8282

83+
:::warning If you use `pgPool`, ensure it has error handlers!
84+
85+
If your `pgPool` doesn't have error handlers then connection issues with the
86+
database may cause your Worker process to exit prematurely.
87+
88+
```ts
89+
import { Pool } from "pg";
90+
const pool = new Pool({
91+
/* ... */
92+
});
93+
94+
/* highlight-start */
95+
// No action necessary
96+
function handleError() {}
97+
pool.on("error", handleError);
98+
pool.on("connect", (client) => void client.on("error", handleError));
99+
/* highlight-end */
100+
```
101+
102+
:::
103+
83104
## `WorkerUtils`
84105

85106
A `WorkerUtils` instance has the following methods:

0 commit comments

Comments
 (0)