1
0
Fork 0

Suggest COMPOSER_DISABLE_NETWORK if a possibly-offline state is detected (#10163)

Co-authored-by: Nils Adermann <naderman@naderman.de>
pull/10169/head
Jordi Boggiano 2021-10-16 09:47:04 +02:00 committed by GitHub
parent 97fe881af4
commit 626370d444
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -305,6 +305,8 @@ class CurlDownloader
*/ */
public function tick() public function tick()
{ {
static $timeoutWarning = false;
if (!$this->jobs) { if (!$this->jobs) {
return; return;
} }
@ -343,6 +345,12 @@ class CurlDownloader
$error = curl_strerror($errno); $error = curl_strerror($errno);
} }
$progress['error_code'] = $errno; $progress['error_code'] = $errno;
if ($errno === 28 /* CURLE_OPERATION_TIMEDOUT */ && isset($progress['namelookup_time']) && $progress['namelookup_time'] == 0 && !$timeoutWarning) {
$timeoutWarning = true;
$this->io->writeError('<warning>A connection timeout was encountered. If you intend to run Composer without connecting to the internet, run the command again prefixed with COMPOSER_DISABLE_NETWORK=1 to make Composer run in offline mode.</warning>');
}
throw new TransportException('curl error '.$errno.' while downloading '.Url::sanitize($progress['url']).': '.$error); throw new TransportException('curl error '.$errno.' while downloading '.Url::sanitize($progress['url']).': '.$error);
} }
$statusCode = $progress['http_code']; $statusCode = $progress['http_code'];