Skip to content

fix(engine): install rustls provider with pools#4975

Merged
NathanFlurry merged 1 commit intomainfrom
engine-pools/install-rustls-provider
May 5, 2026
Merged

fix(engine): install rustls provider with pools#4975
NathanFlurry merged 1 commit intomainfrom
engine-pools/install-rustls-provider

Conversation

@NathanFlurry
Copy link
Copy Markdown
Member

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Copy link
Copy Markdown
Member Author

NathanFlurry commented May 5, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 5, 2026

PR Review: fix(engine): install rustls provider with pools

Overview

This PR moves the rustls CryptoProvider installation into rivet-pools, so any service using Pools::new or Pools::test automatically initializes the provider. This prevents panics in packages that set up TLS connections via pooled clients (reqwest, postgres-rustls, etc.) without going through the guard startup path.


Code Quality

Positive:

  • The install_rustls_provider helper is a clean extraction that avoids copy-paste between Pools::new and Pools::test.
  • The .is_err() pattern with tracing::debug log follows the existing convention in guard/src/lib.rs and envoy-client.
  • The updated comment in guard/src/lib.rs now follows project convention: complete sentence, no trailing dash construction.

Concerns:

  1. Cargo.lock version drift - The workspace Cargo.toml pins rustls to 0.23.25, but Cargo.lock now resolves to 0.23.29. This is an implicit patch bump from adding the dependency to pools. Semantically fine, but worth noting so reviewers do not mistake the lock file change for noise.

  2. Duplicate provider installation - After this change, the engine startup path calls install_rustls_provider twice when guard is also running: once inside Pools::new and once inside guard::start. The second call silently no-ops (by design), but the guard-level call in engine/packages/guard/src/lib.rs is now strictly redundant. Consider removing it to keep a single canonical installation site in pools.

  3. envoy-client still has its own copy - engine/sdks/rust/envoy-client/src/connection/native.rs has a third inline install not deduplicated by this change (it does not depend on rivet-pools). Structurally fine since envoy-client is standalone, but worth a follow-up if more callers appear.


Correctness

The fix is sound. install_default() is idempotent (second call returns Err which is swallowed), and placing it at the top of Pools::new / Pools::test before tokio::try_join! ensures the provider is ready before any DB connections (which may use TLS) are established.


Suggestions

  • Remove the now-redundant call in guard/src/lib.rs now that pools always installs it first.
  • Optional: Use a std::sync::OnceLock so repeated calls avoid constructing a CryptoProvider struct. Not a real concern at this call frequency, but slightly cleaner.

Verdict

Small, low-risk fix. The core change is correct. The main follow-up worth considering is removing the now-redundant guard-level install to avoid confusion about where initialization happens.

@NathanFlurry NathanFlurry force-pushed the engine-pools/install-rustls-provider branch from 25f115a to e745719 Compare May 5, 2026 13:39
Base automatically changed from rivetkit-state/defer-initialized-persist to main May 5, 2026 14:58
@NathanFlurry NathanFlurry merged commit e745719 into main May 5, 2026
4 of 6 checks passed
@NathanFlurry NathanFlurry deleted the engine-pools/install-rustls-provider branch May 5, 2026 14:58
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.

1 participant