Skip to content

Commit 412dc88

Browse files
Don't encourage people to use on('connect') for setup anymore (#3623)
1 parent c6028a8 commit 412dc88

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

docs/pages/apis/pool.mdx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -232,14 +232,11 @@ The number of queued requests waiting on a client when all clients are checked o
232232

233233
`pool.on('connect', (client: Client) => void) => void`
234234

235-
Whenever the pool establishes a new client connection to the PostgreSQL backend it will emit the `connect` event with the newly connected client. This presents an opportunity for you to run setup commands on a client.
235+
Whenever the pool establishes a new client connection to the PostgreSQL backend it will emit the `connect` event with the newly connected client.
236236

237-
```js
238-
const pool = new Pool()
239-
pool.on('connect', (client) => {
240-
client.query('SET DATESTYLE = iso, mdy')
241-
})
242-
```
237+
<Alert>
238+
The event listener does not wait for promises or async functions. If you want to run setup commands on each new client, use the `onConnect` option. (See documentation above.)
239+
</Alert>
243240

244241
### acquire
245242

0 commit comments

Comments
 (0)