Skip to content

feat(sdk): support client-level and per-request timeouts (default: not timeout -> 30 s)#3429

Closed
chengxilo wants to merge 13 commits into
apache:masterfrom
chengxilo:client-timeout
Closed

feat(sdk): support client-level and per-request timeouts (default: not timeout -> 30 s)#3429
chengxilo wants to merge 13 commits into
apache:masterfrom
chengxilo:client-timeout

Conversation

@chengxilo

@chengxilo chengxilo commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR address?

Closes #3419

Rationale

Clients had no deadline on individual request, so a stalled server could block a caller forever.

What changed?

send_raw would be blocked forever if server doesn't response. I added a request_timeout field (IggyDuration, default 30 s) to TcpClientConfig, QuicClientConfig, and WebSocketClientConfig. Each client's send_raw now wraps its I/O in tokio::time::timeout

Use client level timeout

   let client = IggyClientBuilder::new()
          .with_tcp()
          .with_server_address("127.0.0.1:8090".to_string())
          .with_request_timeout(IggyDuration::from_str("5s")?)
          .build()?;

Use the per-request level is

client.ping().with_timeout(IggyDuration::from_str("10ms").unwrap())

Local Execution

  • Passed
  • Pre-commit hooks ran

AI Usage

  1. Claude Opus 4.6
  2. implementation
  3. manually reviewed
  4. Yes Can I?

Change Log

By default, Iggy Rust SDK would have a 30s timeout for each request.

@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown

Thanks for the PR. It is labeled S-waiting-on-review and queued for review.

Slash commands (own line, regular comment) move it around the queue:

  • /ready - back to S-waiting-on-review after addressing feedback
  • /author - flip to S-waiting-on-author while you finish changes
  • /request-review @user-or-team - request a reviewer

See CONTRIBUTING.md for details.

@github-actions github-actions Bot added the S-waiting-on-review PR is waiting on a reviewer label Jun 6, 2026
@codecov

codecov Bot commented Jun 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.39007% with 103 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.22%. Comparing base (78066a6) to head (073c60a).

Files with missing lines Patch % Lines
core/sdk/src/quic/quic_client.rs 85.38% 13 Missing and 6 partials ⚠️
core/sdk/src/clients/client_builder.rs 0.00% 16 Missing ⚠️
core/sdk/src/websocket/websocket_client.rs 88.54% 7 Missing and 8 partials ⚠️
core/sdk/src/client_provider.rs 64.10% 6 Missing and 8 partials ⚠️
core/sdk/src/tcp/tcp_client.rs 86.91% 5 Missing and 9 partials ⚠️
...guration/http_config/http_client_config_builder.rs 0.00% 4 Missing ⚠️
...tion/http_config/http_connection_string_options.rs 76.47% 2 Missing and 2 partials ⚠️
...tion/quic_config/quic_connection_string_options.rs 69.23% 2 Missing and 2 partials ⚠️
...ration/tcp_config/tcp_connection_string_options.rs 69.23% 2 Missing and 2 partials ⚠️
core/sdk/src/http/http_client.rs 95.00% 2 Missing and 2 partials ⚠️
... and 2 more
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3429      +/-   ##
============================================
- Coverage     74.18%   72.22%   -1.97%     
  Complexity      937      937              
============================================
  Files          1261     1262       +1     
  Lines        132045   127654    -4391     
  Branches     107797   103453    -4344     
============================================
- Hits          97958    92196    -5762     
- Misses        30992    32082    +1090     
- Partials       3095     3376     +281     
Components Coverage Δ
Rust Core 72.42% <85.39%> (-2.39%) ⬇️
Java SDK 62.44% <ø> (ø)
C# SDK 71.40% <ø> (-0.71%) ⬇️
Python SDK 90.87% <ø> (ø)
PHP SDK 84.29% <ø> (ø)
Node SDK 91.35% <ø> (+0.09%) ⬆️
Go SDK 40.14% <ø> (ø)
Files with missing lines Coverage Δ
core/common/src/error/iggy_error.rs 100.00% <ø> (ø)
...es/configuration/http_config/http_client_config.rs 100.00% <100.00%> (ø)
...es/configuration/quic_config/quic_client_config.rs 100.00% <100.00%> (ø)
...guration/quic_config/quic_client_config_builder.rs 36.60% <100.00%> (+7.60%) ⬆️
...ypes/configuration/tcp_config/tcp_client_config.rs 100.00% <100.00%> (ø)
...figuration/tcp_config/tcp_client_config_builder.rs 71.55% <100.00%> (+3.51%) ⬆️
...ration/websocket_config/websocket_client_config.rs 62.35% <100.00%> (+0.90%) ⬆️
...ebsocket_config/websocket_client_config_builder.rs 37.96% <100.00%> (+7.75%) ⬆️
core/common/src/utils/duration.rs 86.45% <100.00%> (+0.83%) ⬆️
core/sdk/src/consumer_ext/consumer_message_ext.rs 0.00% <ø> (ø)
... and 14 more

... and 128 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread core/common/src/types/configuration/quic_config/quic_client_config.rs Outdated
Comment thread core/sdk/src/tcp/tcp_client.rs Outdated
Comment thread core/sdk/src/websocket/websocket_client.rs Outdated
Comment thread core/sdk/src/tcp/tcp_client.rs Outdated
Comment thread core/sdk/src/quic/quic_client.rs Outdated
Comment thread core/common/src/types/configuration/tcp_config/tcp_client_config.rs Outdated
Comment thread core/sdk/src/tcp/tcp_client.rs Outdated
Comment thread core/sdk/src/client_provider.rs Outdated
Comment thread core/common/src/types/configuration/tcp_config/tcp_client_config.rs Outdated
Comment thread core/common/src/types/configuration/tcp_config/tcp_client_config.rs
@github-actions github-actions Bot added S-waiting-on-author PR is waiting on author response and removed S-waiting-on-review PR is waiting on a reviewer labels Jun 9, 2026
@chengxilo
chengxilo requested a review from hubcio June 17, 2026 01:08
@chengxilo

Copy link
Copy Markdown
Contributor Author

/ready

@github-actions github-actions Bot added S-waiting-on-review PR is waiting on a reviewer and removed S-waiting-on-author PR is waiting on author response labels Jun 17, 2026
@chengxilo

Copy link
Copy Markdown
Contributor Author

/author

@chengxilo

Copy link
Copy Markdown
Contributor Author

After merging there is something need to be changed.

@github-actions github-actions Bot added S-waiting-on-author PR is waiting on author response and removed S-waiting-on-review PR is waiting on a reviewer labels Jun 21, 2026
@chengxilo

Copy link
Copy Markdown
Contributor Author

/ready

@github-actions github-actions Bot added S-waiting-on-review PR is waiting on a reviewer and removed S-waiting-on-author PR is waiting on author response labels Jun 21, 2026

@hubcio hubcio left a comment

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.

a few findings that don't map onto changed lines:

  • the consumer poll loop error classifier (consumer.rs) only treats Disconnected | Unauthenticated | StaleClient as connection errors, so a RequestTimeout (and NotConnected) falls through as a raw error with can_poll left true and no backoff, on every transport. this is the real root of the quic no-recovery behavior noted in the quic comment. consumer.rs isn't touched by this PR so flagging it here.
  • the PR description says default 300s but the code is 30s everywhere (a later commit reduced it). update the description.
  • no test for the is_zero() no-timeout branch, nor for the vsr session-reset-on-timeout path.
  • the timeout is rust-sdk only; java/.net/python/go/c++/node don't get it - worth filing parity issues later on

Comment thread core/sdk/src/tcp/tcp_client.rs Outdated
Comment thread core/sdk/src/tcp/tcp_client.rs
Comment thread core/sdk/src/tcp/tcp_client.rs Outdated
Comment thread core/sdk/src/tcp/tcp_client.rs Outdated
Comment thread core/sdk/src/quic/quic_client.rs Outdated
Comment thread core/sdk/src/client_provider.rs
Comment thread core/common/src/types/args/mod.rs Outdated
@github-actions github-actions Bot added S-waiting-on-author PR is waiting on author response and removed S-waiting-on-review PR is waiting on a reviewer labels Jun 23, 2026
@chengxilo chengxilo changed the title feat(sdk): support per-request timeout to TCP/QUIC/WebSocket clients feat(sdk): support per-request timeout Jul 2, 2026
@chengxilo
chengxilo force-pushed the client-timeout branch 2 times, most recently from df904fa to 605a84b Compare July 2, 2026 20:30
@chengxilo chengxilo changed the title feat(sdk): support per-request timeout feat(sdk): support client-level and per-request timeouts Jul 2, 2026
@chengxilo chengxilo changed the title feat(sdk): support client-level and per-request timeouts feat(sdk): support client-level and per-request timeouts (default: not timeout -> 30 s) Jul 3, 2026
chengxilo added 10 commits July 2, 2026 22:10
- Acquire stream lock outside timeout region to avoid counting
  lock-wait time against the request budget
- Emit DiagnosticEvent::Disconnected and null stream/connection
  on timeout for all transports (TCP, QUIC, WebSocket)
- Preserve client_id on VSR session reset after timeout
- Classify RequestTimeout as a connection error in consumer poll loop
- Wire request_timeout into HTTP transport via reqwest timeout
- Add request_timeout to HTTP connection string options
- Add IggyDuration::is_zero() and document zero-timeout behavior
- Add timeout and zero-timeout tests for TCP, WebSocket, HTTP
- Add VSR session-reset-on-timeout tests for TCP and WebSocket
@chengxilo

chengxilo commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

I thought I can make the commit history more clean so I used rebase + force push. But it doesn't end up well so I have to note it here. The changes after the second code review start from fix(sdk): address code review feedback for per-request timeout.

I added a per-request level timeout in feat(sdk): provide per-request timeout to override the client level one. I think we should also provide it so the caller can have a better control over their request.

The way we can use the per-request level is

client.ping().with_timeout(IggyDuration::from_str("10ms").unwrap())

@chengxilo

Copy link
Copy Markdown
Contributor Author

/ready

@chengxilo
chengxilo requested a review from hubcio July 3, 2026 03:19
@github-actions github-actions Bot added S-waiting-on-review PR is waiting on a reviewer and removed S-waiting-on-author PR is waiting on author response labels Jul 3, 2026
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.

Support per-request timeout to TCP/QUIC/WebSocket/Http clients

2 participants