Skip to content

Commit d7efaab

Browse files
committed
There are cases where CURLE_OPERATION_TIMEDOUT is returned even though we have not set a timeout. Keep track of transaction time in Transaction.
1 parent 793348d commit d7efaab

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/Browser.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
use function preg_split;
5050
use function property_exists;
5151
use function rewind;
52+
use function round;
5253
use function str_contains;
5354
use function stream_get_contents;
5455
use function stream_set_blocking;
@@ -545,7 +546,7 @@ private function curlTick(): void
545546
} else {
546547
unset($this->inProgress[$mh]);
547548
if ($info['result'] === CURLE_OPERATION_TIMEDOUT) {
548-
$deferred->reject(new \RuntimeException('Request timed out after ' . $this->timeout . ' seconds'), CURLE_OPERATION_TIMEDOUT);
549+
$deferred->reject(new \RuntimeException('Request timed out after ' . round((hrtime(true) - $transaction->start)/1e+9, 1) . ' seconds'), CURLE_OPERATION_TIMEDOUT);
549550
} else {
550551
$deferred->reject(new \RuntimeException(curl_strerror($info['result']), $info['result']));
551552
}

src/Transaction.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ final class Transaction {
2525

2626
private bool $closed = false;
2727

28-
public function __construct(public \CurlMultiHandle $multi, public CurlHandle $curl, public Deferred $deferred, public $file, public $headers) {
28+
public readonly float $start;
2929

30+
public function __construct(public \CurlMultiHandle $multi, public CurlHandle $curl, public Deferred $deferred, public $file, public $headers) {
31+
$this->start = hrtime(true);
3032
}
3133

3234
public function close() : void {

0 commit comments

Comments
 (0)