Skip to content

fix: Make query-side AnnotatedQuery forwarders Send-clean - #31

Merged
chmodas merged 1 commit into
trunkfrom
hrtb-issue
May 3, 2026
Merged

fix: Make query-side AnnotatedQuery forwarders Send-clean#31
chmodas merged 1 commit into
trunkfrom
hrtb-issue

Conversation

@chmodas

@chmodas chmodas commented May 3, 2026

Copy link
Copy Markdown
Owner

The fetch_*/execute methods on AnnotatedQuery were declared as async fn, which generated a coroutine state machine on this crate's side. Inside that coroutine, rustc's auto-trait Send inference had to discharge the HRTB for<'a> &'a mut DB::Connection: sqlx::Executor<'a, ...> carried by the IntoAnnotatedExecutor impls – and could not, breaking query-side annotation inside tokio::spawn, axum handlers, and tower::Service-bounded futures.

Convert the five forwarders (fetch_optional, fetch_all, fetch_one, execute, execute_many) from async fn -> T to `fn -> impl Future<Output = T> + Send

  • 'e. The body forwards sqlx's underlying future directly with no .await`, so no coroutine forms at this layer; Send delegates to sqlx's own already-Send future. The HRTB on the IntoAnnotatedExecutor impls and on impl_executor! is unchanged, and the executor-side surface is unaffected.

The fetch_*/execute methods on AnnotatedQuery were declared as `async fn`,
which generated a coroutine state machine on this crate's side. Inside that
coroutine, rustc's auto-trait Send inference had to discharge the HRTB
`for<'a> &'a mut DB::Connection: sqlx::Executor<'a, ...>` carried by the
IntoAnnotatedExecutor impls – and could not, breaking query-side annotation
inside tokio::spawn, axum handlers, and tower::Service-bounded futures.

Convert the five forwarders (fetch_optional, fetch_all, fetch_one, execute,
execute_many) from `async fn -> T` to `fn -> impl Future<Output = T> + Send
+ 'e`. The body forwards sqlx's underlying future directly with no `.await`,
so no coroutine forms at this layer; Send delegates to sqlx's own
already-Send future. The HRTB on the IntoAnnotatedExecutor impls and on
impl_executor! is unchanged, and the executor-side surface is unaffected.
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.90%. Comparing base (cc812e5) to head (7fb8306).
⚠️ Report is 1 commits behind head on trunk.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##            trunk      #31   +/-   ##
=======================================
  Coverage   99.90%   99.90%           
=======================================
  Files          12       12           
  Lines        2030     2034    +4     
=======================================
+ Hits         2028     2032    +4     
  Misses          2        2           

☔ View full report in Codecov by Sentry.
📢 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.

@chmodas
chmodas merged commit edc9e30 into trunk May 3, 2026
2 checks passed
@chmodas
chmodas deleted the hrtb-issue branch May 3, 2026 20:42
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.

2 participants