I've been troubleshooting some connection errors in my application and I've tracked them down to a couple issues in ConnectionLimitingPool:
In getStreamFor, when a new connection is created, the connection ID is captured so it can be passed to dropConnection when the connection is closed. But what it's actually capturing is the ID of the connection promise, not the connection itself. This causes dropConnection to not correctly remove the connection from activeRequestCounts and idleConnections.
The onReadyConnection method closes idle connections if it detects that there are too many open. But it does so with array_shift, which re-indexes the array starting from 0, so the remaining idle connections are no longer mapped to the correct connection ID.
These errors result in connections not being removed the list of idle connections when they should be, which can lead to connections being closed while still in use. I'll submit a PR for this momentarily.
I've been troubleshooting some connection errors in my application and I've tracked them down to a couple issues in ConnectionLimitingPool:
getStreamFor
, when a new connection is created, the connection ID is captured so it can be passed todropConnection
when the connection is closed. But what it's actually capturing is the ID of the connection promise, not the connection itself. This causesdropConnection
to not correctly remove the connection fromactiveRequestCounts
andidleConnections
.onReadyConnection
method closes idle connections if it detects that there are too many open. But it does so witharray_shift
, which re-indexes the array starting from 0, so the remaining idle connections are no longer mapped to the correct connection ID.These errors result in connections not being removed the list of idle connections when they should be, which can lead to connections being closed while still in use. I'll submit a PR for this momentarily.