Skip to content

Add timeouts for HTTP requests#3541

Merged
jvff merged 4 commits intolinera-io:mainfrom
jvff:epoch-configurable-http-timeouts
Mar 11, 2025
Merged

Add timeouts for HTTP requests#3541
jvff merged 4 commits intolinera-io:mainfrom
jvff:epoch-configurable-http-timeouts

Conversation

@jvff
Copy link
Copy Markdown
Contributor

@jvff jvff commented Mar 11, 2025

Motivation

HTTP requests can take a long time to complete, or attempt to stay open indefinitely. This should not be allowed because it may stall a chain.

Proposal

Add a http_request_timeout policy to ResourceControlPolicy, and configure all HTTP requests to use that timeout.

Test Plan

Wrote some tests out of this branch, possibly to be added to #3509.

Release Plan

  • Backporting is not possible but we may want to deploy a new devnet and testnet and release a new
    SDK soon, because this contains backwards incompatible changes to the chain state.

Links

@jvff jvff added the security label Mar 11, 2025
@jvff jvff requested review from afck, bart-linera, deuszx and ma2bd March 11, 2025 05:31
@jvff jvff self-assigned this Mar 11, 2025
jvff added 2 commits March 11, 2025 06:23
Don't condition it to having depleted its expected calls.
Allow writing tests where the application calls its service as an
oracle.
@jvff jvff force-pushed the epoch-configurable-http-timeouts branch from 4cec7ea to 20932c5 Compare March 11, 2025 06:25
jvff added 2 commits March 11, 2025 07:33
Allow configuring the timeout for HTTP requests.
Ensure that it takes a bounded amount of time to complete.
@jvff jvff force-pushed the epoch-configurable-http-timeouts branch from 20932c5 to f74cb21 Compare March 11, 2025 07:33
.send()
.await?;
.headers(headers);
#[cfg(not(web))]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

…or use the same timeout in either case? Might be less surprising, too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't, reqwest doesn't support timeouts on Wasm :/


let response = Client::new()
#[cfg_attr(web, allow(unused_mut))]
let mut request = Client::new()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So on a web client there won't be any timeouts?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only the default browser timeouts. Unfortunately we can't add timeouts with reqwest for Wasm, we'd need to use Javascript APIs directly :(

@jvff jvff merged commit 3d528c1 into linera-io:main Mar 11, 2025
23 checks passed
@jvff jvff deleted the epoch-configurable-http-timeouts branch March 11, 2025 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Epoch configurable HTTP timeouts

3 participants