Skip to content

Raise curl connection timeout threshold from 5 to 10 seconds#1439

Merged
edmorley merged 1 commit intomainfrom
raise-connect-timeouts
Apr 11, 2023
Merged

Raise curl connection timeout threshold from 5 to 10 seconds#1439
edmorley merged 1 commit intomainfrom
raise-connect-timeouts

Conversation

@edmorley
Copy link
Copy Markdown
Member

To support environments where it takes longer than 5 seconds to establish the HTTPS connection (such as Dokku).

Fixes #1436.
GUS-W-13013203.

@edmorley edmorley self-assigned this Apr 11, 2023
@edmorley edmorley changed the title Raise Curl connection timeout threshold from 5 to 10 seconds Raise curl connection timeout threshold from 5 to 10 seconds Apr 11, 2023
To support environments where it takes longer than 5 seconds to establish the
HTTPS connection (such as Dokku).

Fixes #1436.
GUS-W-13013203.
@edmorley edmorley merged commit d12bb30 into main Apr 11, 2023
@edmorley edmorley deleted the raise-connect-timeouts branch April 11, 2023 17:08
@edmorley edmorley mentioned this pull request Apr 11, 2023
edmorley added a commit that referenced this pull request Aug 24, 2025
In #1439, the timeouts used with curl were set to higher values than
we needed for Heroku's build system, in order to prevent timeouts in
non-Heroku environments such as Dokku running on underpowered devices
(or devices with poor internet connections).

However, as seen in recent Honeycomb metrics, these higher timeouts
cause longer delays on Heroku before a curl retry if there is a
transient S3 connection issue - since the request will wait the full
10 seconds `connect_timeout` before retrying.

As such, the defaults have been lowered again to be optimised for
running on Heroku, and support for overriding the defaults via env var
added to still allow running in other environments.

Specifically:
- The default connection timeout has been lowered from 10 seconds to 3,
  but can now be overridden via the env var `CURL_CONNECT_TIMEOUT`
- The default total request timeout has been lowered from 120 seconds
  to 60, but can be overridden via `CURL_TIMEOUT`

These env vars cannot be set via Heroku config vars, and must instead
be set in the build system environment (or by an earlier buildpack).
The env var names match those used by the classic Ruby buildpack:
https://github.com/heroku/heroku-buildpack-ruby/blob/a6d124492aafe7f7ee0dd42d7a79284b6552d675/lib/language_pack/fetcher.rb#L47-L53

In addition, the usages of `--silent --show-error` have been replaced
with `--no-progress-meter`, which is otherwise identical apart from it
allowing warnings to be shown, such as the status messages output during
retry attempts (of form: "Will retry in 1 seconds. 3 retries left" etc).

Before:

```
-----> Installing Python 3.13.7
       curl: (6) Could not resolve host: heroku-buildpack-python.s3.us-east-1.amazonaws.com
       curl: (6) Could not resolve host: heroku-buildpack-python.s3.us-east-1.amazonaws.com
       ...
```

After:

```
-----> Installing Python 3.13.7
       curl: (7) Failed to connect to heroku-buildpack-python.s3.us-east-1.amazonaws.com port 443 after 3 ms: Couldn't connect to server
       Warning: Problem : connection refused. Will retry in 1 seconds. 5 retries left.
       curl: (7) Failed to connect to heroku-buildpack-python.s3.us-east-1.amazonaws.com port 443 after 4 ms: Couldn't connect to server
       Warning: Problem : connection refused. Will retry in 2 seconds. 4 retries left.
       ...
```

Lastly, the maximum number of retries has been increased slightly.

Note: The curl options used in `build_python_runtime.sh` have also been
adjusted, however, since these are only used by buildpack maintainers
(typically by running them on GitHub Actions), there is no need to those
timeouts configurable.

GUS-W-19414036.
edmorley added a commit that referenced this pull request Aug 24, 2025
In #1439, the timeouts used with curl were set to higher values than
we needed for Heroku's build system, in order to prevent timeouts in
non-Heroku environments such as Dokku running on underpowered devices
(or devices with poor internet connections).

However, as seen in recent Honeycomb metrics, these higher timeouts
cause longer delays on Heroku before a curl retry if there is a
transient S3 connection issue - since the request will wait the full
10 seconds `connect_timeout` before retrying.

As such, the defaults have been lowered again to be optimised for
running on Heroku, and support for overriding the defaults via env var
added to still allow running in other environments.

Specifically:
- The default connection timeout has been lowered from 10 seconds to 3,
  but can now be overridden via the env var `CURL_CONNECT_TIMEOUT`
- The default total request timeout has been lowered from 120 seconds
  to 60, but can be overridden via `CURL_TIMEOUT`

These env vars cannot be set via Heroku config vars, and must instead
be set in the build system environment (or by an earlier buildpack).
The env var names match those used by the classic Ruby buildpack:
https://github.com/heroku/heroku-buildpack-ruby/blob/a6d124492aafe7f7ee0dd42d7a79284b6552d675/lib/language_pack/fetcher.rb#L47-L53

In addition, the usages of `--silent --show-error` have been replaced
with `--no-progress-meter`, which is otherwise identical apart from it
allowing warnings to be shown, such as the status messages output during
retry attempts (of form: "Will retry in 1 seconds. 3 retries left" etc).

Before:

```
-----> Installing Python 3.13.7
       curl: (6) Could not resolve host: heroku-buildpack-python.s3.us-east-1.amazonaws.com
       curl: (6) Could not resolve host: heroku-buildpack-python.s3.us-east-1.amazonaws.com
       ...
```

After:

```
-----> Installing Python 3.13.7
       curl: (7) Failed to connect to heroku-buildpack-python.s3.us-east-1.amazonaws.com port 443 after 3 ms: Couldn't connect to server
       Warning: Problem : connection refused. Will retry in 1 seconds. 5 retries left.
       curl: (7) Failed to connect to heroku-buildpack-python.s3.us-east-1.amazonaws.com port 443 after 4 ms: Couldn't connect to server
       Warning: Problem : connection refused. Will retry in 2 seconds. 4 retries left.
       ...
```

Lastly, the maximum number of retries has been increased slightly.

Note: The curl options used in `build_python_runtime.sh` have also been
adjusted, however, since these are only used by buildpack maintainers
(typically by running them on GitHub Actions), there is no need to those
timeouts configurable.

GUS-W-19414036.
edmorley added a commit that referenced this pull request Aug 24, 2025
In #1439, the timeouts used with curl were set to higher values than we
needed for Heroku's build system, in order to prevent timeouts in
non-Heroku environments such as Dokku running on underpowered devices
(or devices with poor internet connections).

However, as seen in recent Honeycomb metrics, these higher timeouts
cause longer delays on Heroku before a curl retry if there is a
transient S3 connection issue - since the request will wait the full 10
seconds `connect_timeout` before retrying.

As such, the defaults have been lowered again to be optimised for
running on Heroku, and support for overriding the defaults via env var
added to still allow running in other environments.

Specifically:
- The default connection timeout has been lowered from 10 seconds to 3,
  but can now be overridden via the env var `CURL_CONNECT_TIMEOUT`
- The default total request timeout has been lowered from 120 seconds
  to 60, but can be overridden via `CURL_TIMEOUT`

These env vars cannot be set via Heroku config vars, and must instead be
set in the build system environment (or by an earlier buildpack).

The env var names match those used by the classic Ruby buildpack:
https://github.com/heroku/heroku-buildpack-ruby/blob/a6d124492aafe7f7ee0dd42d7a79284b6552d675/lib/language_pack/fetcher.rb#L47-L53

In addition, the usages of `--silent --show-error` have been replaced
with `--no-progress-meter`, which is otherwise identical apart from it
allowing warnings to be shown, such as the status messages output during
retry attempts (of form: `Will retry in 1 seconds. 3 retries left` etc).

Before:

```
-----> Installing Python 3.13.7
       curl: (6) Could not resolve host: heroku-buildpack-python.s3.us-east-1.amazonaws.com
       curl: (6) Could not resolve host: heroku-buildpack-python.s3.us-east-1.amazonaws.com
       ...
```

After:

```
-----> Installing Python 3.13.7
       curl: (7) Failed to connect to heroku-buildpack-python.s3.us-east-1.amazonaws.com port 443 after 3 ms: Couldn't connect to server
       Warning: Problem : connection refused. Will retry in 1 seconds. 5 retries left.
       curl: (7) Failed to connect to heroku-buildpack-python.s3.us-east-1.amazonaws.com port 443 after 4 ms: Couldn't connect to server
       Warning: Problem : connection refused. Will retry in 2 seconds. 4 retries left.
       ...
```

Lastly, the maximum number of retries has been increased slightly.

Note: The curl options used in `build_python_runtime.sh` have also been
adjusted, however, since these are only used by buildpack maintainers
(typically by running them on GitHub Actions), there is no need to make
those timeouts configurable.

GUS-W-19414036.
edmorley added a commit that referenced this pull request Aug 24, 2025
In #1439, the timeouts used with curl were set to higher values than we
needed for Heroku's build system, in order to prevent timeouts in
non-Heroku environments such as Dokku running on underpowered devices
(or devices with poor internet connections).

However, as seen in recent Honeycomb metrics, these higher timeouts
cause longer delays on Heroku before a curl retry if there is a
transient S3 connection issue - since the request will wait the full 10
seconds `connect_timeout` before retrying.

As such, the defaults have been lowered again to be optimised for
running on Heroku, and support for overriding the defaults via env var
added to still allow running in other environments.

Specifically:
- The default connection timeout has been lowered from 10 seconds to 3,
  but can now be overridden via the env var `CURL_CONNECT_TIMEOUT`
- The default total request timeout has been lowered from 120 seconds
  to 60, but can be overridden via `CURL_TIMEOUT`

These env vars cannot be set via Heroku config vars, and must instead be
set in the build system environment (or by an earlier buildpack).

The env var names match those used by the classic Ruby buildpack:
https://github.com/heroku/heroku-buildpack-ruby/blob/a6d124492aafe7f7ee0dd42d7a79284b6552d675/lib/language_pack/fetcher.rb#L47-L53

In addition, the usages of `--silent --show-error` have been replaced
with `--no-progress-meter`, which is otherwise identical apart from it
allowing warnings to be shown, such as the status messages output during
retry attempts (of form: `Will retry in 1 seconds. 3 retries left` etc).

Before:

```
-----> Installing Python 3.13.7
       curl: (6) Could not resolve host: heroku-buildpack-python.s3.us-east-1.amazonaws.com
       curl: (6) Could not resolve host: heroku-buildpack-python.s3.us-east-1.amazonaws.com
       ...
```

After:

```
-----> Installing Python 3.13.7
       curl: (7) Failed to connect to heroku-buildpack-python.s3.us-east-1.amazonaws.com port 443 after 3 ms: Couldn't connect to server
       Warning: Problem : connection refused. Will retry in 1 seconds. 5 retries left.
       curl: (7) Failed to connect to heroku-buildpack-python.s3.us-east-1.amazonaws.com port 443 after 4 ms: Couldn't connect to server
       Warning: Problem : connection refused. Will retry in 2 seconds. 4 retries left.
       ...
```

Lastly, the maximum number of retries has been increased slightly.

Note: The curl options used in `build_python_runtime.sh` have also been
adjusted, however, since these are only used by buildpack maintainers
(typically by running them on GitHub Actions), there is no need to make
those timeouts configurable.

GUS-W-19414036.
edmorley added a commit that referenced this pull request Aug 26, 2025
In #1439, the timeouts used with curl were set to higher values than we
needed for Heroku's build system, in order to prevent timeouts in
non-Heroku environments such as Dokku running on underpowered devices
(or devices with poor internet connections).

However, as seen in recent Honeycomb metrics, these higher timeouts
cause longer delays on Heroku before a curl retry if there is a
transient S3 connection issue - since the request will wait the full 10
seconds `connect_timeout` before retrying.

As such, the defaults have been lowered again to be optimised for
running on Heroku, and support for overriding the defaults via env var
added to still allow running in other environments.

Specifically:
- The default connection timeout has been lowered from 10 seconds to 3,
  but can now be overridden via the env var `CURL_CONNECT_TIMEOUT`
- The default total request timeout has been lowered from 120 seconds
  to 60, but can be overridden via `CURL_TIMEOUT`

These env vars cannot be set via Heroku config vars, and must instead be
set in the build system environment (or by an earlier buildpack).

The env var names match those used by the classic Ruby buildpack:
https://github.com/heroku/heroku-buildpack-ruby/blob/a6d124492aafe7f7ee0dd42d7a79284b6552d675/lib/language_pack/fetcher.rb#L47-L53

In addition, the usages of `--silent --show-error` have been replaced
with `--no-progress-meter`, which is otherwise identical apart from it
allowing warnings to be shown, such as the status messages output during
retry attempts (of form: `Will retry in 1 seconds. 3 retries left` etc).

Before:

```
-----> Installing Python 3.13.7
       curl: (6) Could not resolve host: heroku-buildpack-python.s3.us-east-1.amazonaws.com
       curl: (6) Could not resolve host: heroku-buildpack-python.s3.us-east-1.amazonaws.com
       ...
```

After:

```
-----> Installing Python 3.13.7
       curl: (7) Failed to connect to heroku-buildpack-python.s3.us-east-1.amazonaws.com port 443 after 3 ms: Couldn't connect to server
       Warning: Problem : connection refused. Will retry in 1 seconds. 5 retries left.
       curl: (7) Failed to connect to heroku-buildpack-python.s3.us-east-1.amazonaws.com port 443 after 4 ms: Couldn't connect to server
       Warning: Problem : connection refused. Will retry in 2 seconds. 4 retries left.
       ...
```

Lastly, the maximum number of retries has been increased slightly.

Note: The curl options used in `build_python_runtime.sh` have also been
adjusted, however, since these are only used by buildpack maintainers
(typically by running them on GitHub Actions), there is no need to make
those timeouts configurable.

GUS-W-19414036.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Requested runtime 'python-3.X.Y' is not available for this stack due to hitting curl connection timeouts on Dokku

2 participants