fix: throw InvalidArgumentException for non-positive timeouts

Previously readTimeout <= 0 was silently coerced to 0.25s. Better
to fail loudly so misconfiguration surfaces during testing rather
than masking the user's intent at runtime. Apply the same rule to
the connect timeout.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
loks0nandClaude Opus 4.7 committed 2026-05-12 15:50:41 +01:00
1 parent 611c141612
commit 2dbb72833a
1 file changed
+4 -1
+4 -1
View File
@@ -56,8 +56,11 @@ class Multiplexing implements Adapter, TelemetryFeature
private string|array|null $auth = null,
private int $dbIndex = 0,
) {
if ($this->timeout <= 0) {
throw new \InvalidArgumentException('timeout must be greater than 0');
}
if ($this->readTimeout <= 0) {
$this->readTimeout = 0.25;
throw new \InvalidArgumentException('readTimeout must be greater than 0');
}
$this->sendLock = new Lock();
$this->setTelemetry(new NoTelemetry());