Skip to content

Commit a09f35e

Browse files
Dan Bernardicdougwilson
Dan Bernardic
authored andcommitted
docs: add pool.end() documentation
closes #911 closes #912
1 parent a4dd3dc commit a09f35e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Readme.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,22 @@ pool.on('enqueue', function () {
364364
});
365365
```
366366

367+
## Closing all the connections in a pool
368+
369+
When you are done using the pool, you have to end all the connections or your
370+
script will hang until the db server closes them. To end all the connections
371+
in the pool, use the `end` method on the pool:
372+
373+
```js
374+
pool.end(function (err) {
375+
// all connections in the pool have ended
376+
});
377+
```
378+
379+
The `end` method takes an _optional_ callback that you can use to know once
380+
all the connections have ended. The connections end _gracefully_, so all
381+
pending queries will still complete and the time to end the pool will vary.
382+
367383
## PoolCluster
368384

369385
PoolCluster provides multiple hosts connection. (group & retry & selector)

0 commit comments

Comments
 (0)