Skip to content

fix: Keep TransportBuilder Send and Sync - #518

Merged
reta merged 1 commit into
opensearch-project:mainfrom
krocky-cooky:fix/client-initializer-send
Nov 13, 2026
Merged

reta merged 1 commit into
opensearch-project:mainfrom
krocky-cooky:fix/client-initializer-send

Conversation

@krocky-cooky

Copy link
Copy Markdown
Contributor

Description

TransportBuilder stopped being Send and Sync when the middleware types were added (#232): it stores its client initializers as boxed ClientInitializers, and that trait had no Send or Sync bound. The builder lost both auto traits even without any initializer, so a builder held across .await could no longer be moved into a spawned task, which worked in 2.x.

This PR requires Send + Sync on ClientInitializer and on its closure impl, as RequestInitializer and RequestHandler already do. Initializers capturing non-thread-safe state (e.g. an Rc) are no longer accepted; since middleware is unreleased, no released code is affected.

Tests

  • TransportBuilder and Transport are Send + Sync (a compile-time check, so a regression fails the build).
  • A builder with a client initializer is built on another thread.

Testing

  • cargo test -p opensearch --lib http::: 32 passed; transport doc tests: 5 passed.
  • cargo fmt --check clean; no new clippy warnings.

Issues Resolved

Closes #517.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 License.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

ClientInitializer had no Send or Sync bound, so the boxed initializers
stored in TransportBuilder made the builder neither Send nor Sync, even
when no initializer was added. A builder held across .await could no
longer be moved into a spawned task, which worked in 2.x.

Require Send + Sync on ClientInitializer and its closure impl, as
RequestInitializer and RequestHandler already do, and test that
TransportBuilder and Transport are Send + Sync.

Signed-off-by: Takuo Kuroki <kurotaku9679.sub@gmail.com>
@codecov

codecov Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 46.91%. Comparing base (c5381ae) to head (c232e8f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #518      +/-   ##
==========================================
+ Coverage   44.30%   46.91%   +2.60%     
==========================================
  Files         569      569              
  Lines      169350   170879    +1529     
==========================================
+ Hits        75030    80165    +5135     
+ Misses      94320    90714    -3606     
Flag Coverage Δ
integration 45.12% <ø> (+2.71%) ⬆️
unit 7.95% <ø> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@reta reta left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @krocky-cooky ! Indeed, looks like a regression against 2.x

@reta
reta merged commit ce222ef into opensearch-project:main Nov 13, 2026
42 checks passed
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.

[BUG] TransportBuilder is no longer Send or Sync

2 participants