Skip to content

Add optional parameter to configuration providers for non-blocking startup#1745

Draft
GeorgeTsiokos wants to merge 1 commit intodapr:masterfrom
GeorgeTsiokos:feature/optional-config-resilience
Draft

Add optional parameter to configuration providers for non-blocking startup#1745
GeorgeTsiokos wants to merge 1 commit intodapr:masterfrom
GeorgeTsiokos:feature/optional-config-resilience

Conversation

@GeorgeTsiokos
Copy link

@GeorgeTsiokos GeorgeTsiokos commented Mar 13, 2026

Summary

  • Adds an optional parameter to AddDaprConfigurationStore, AddStreamingDaprConfigurationStore, and AddDaprSecretStore extension methods so applications can start without blocking on Dapr sidecar availability
  • Hardens LoadInBackgroundAsync in both providers with narrowed exception handling (OperationCanceledException + DaprException) instead of a broad catch (Exception) that silently swallowed programming errors
  • Fixes resource leak by disposing CancellationTokenSource in both providers
  • Fixes StringComparer inconsistency (InvariantCultureIgnoreCaseOrdinalIgnoreCase) in FetchSecretsAsync
  • Makes fields readonly in DaprConfigurationStoreProvider for consistency with DaprSecretStoreConfigurationProvider
  • Restores UTF-8 BOM per .editorconfig and adds missing trailing newlines

Test plan

  • All 52 existing + new tests pass across net8.0, net9.0, net10.0
  • New tests use GetReloadToken() callbacks for deterministic assertions (no fragile Task.Delay polling)
  • Verify optional: true with real Dapr sidecar (sidecar down at startup → starts later → config populates)
  • Verify optional: false (default) behavior unchanged — blocks startup as before
  • Verify disposal during background loading exits cleanly without hanging

🤖 Generated with Claude Code

…artup

Configuration and secret store providers now accept an `optional` parameter
that allows applications to start without blocking on sidecar availability.
When optional, configuration loads in the background with resilient retry
logic that handles transient Dapr errors gracefully.

- Add `optional` parameter to AddDaprConfigurationStore and AddDaprSecretStore
- Harden LoadInBackgroundAsync to catch OperationCanceledException and
  DaprException separately, avoiding silent swallowing of programming errors
- Dispose CancellationTokenSource in both providers to prevent resource leaks
- Fix StringComparer inconsistency (InvariantCultureIgnoreCase → OrdinalIgnoreCase)
- Mark fields readonly in DaprConfigurationStoreProvider for consistency
- Restore UTF-8 BOM per .editorconfig and add missing trailing newlines
- Add deterministic tests using reload tokens instead of fragile Task.Delay

Fixes dapr#993 dapr#345 dapr#1403

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: George Tsiokos <george@tsiokos.com>
@GeorgeTsiokos GeorgeTsiokos requested review from a team as code owners March 13, 2026 10:37
@GeorgeTsiokos GeorgeTsiokos marked this pull request as draft March 13, 2026 11:47
@WhitWaldo
Copy link
Contributor

Do note that I just merged a PR to support xUnit v3 so your unit/integration tests may need a refresh.

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