Skip to content

Delay connection validation - #213

Merged
Eric Erhardt (eerhardt) merged 2 commits into
mainfrom
DelayConnectionFailures
Oct 13, 2023
Merged

Eric Erhardt (eerhardt) merged 2 commits into
mainfrom
DelayConnectionFailures

Conversation

@eerhardt

Copy link
Copy Markdown
Member

When an app is deployed to a new environment, it is common for the connection information to be missing initially. When this is the case, the app crashes very early (inline when calling AddXXX for the component). When throwing this early, there isn't an ILogger which can log the exception, and thus the exception is written to stderr/stdout by the .NET runtime. This isn't ideal since certain environments expect stdout logs to be in a certain format.

The fix is to delay the connection validation until the underlying DI service is requested/created. At this point the DI container is built, and the app can log an exception with the configured ILogger.

Fix #185

When an app is deployed to a new environment, it is common for the connection information to be missing initially. When this is the case, the app crashes very early (inline when calling AddXXX for the component). When throwing this early, there isn't an ILogger which can log the exception, and thus the exception is written to stderr/stdout by the .NET runtime. This isn't ideal since certain environments expect stdout logs to be in a certain format.

The fix is to delay the connection validation until the underlying DI service is requested/created. At this point the DI container is built, and the app can log an exception with the configured ILogger.

Fix #185
@eerhardt

Copy link
Copy Markdown
Member Author

FYI - I plan on merging this by EOD.

@eerhardt
Eric Erhardt (eerhardt) merged commit 58a7096 into main Oct 13, 2023
@eerhardt
Eric Erhardt (eerhardt) deleted the DelayConnectionFailures branch October 13, 2023 02:40
@danmoseley Dan Moseley (danmoseley) added the area-integrations Issues pertaining to Aspire Integrations packages label Nov 16, 2023
@github-actions github-actions Bot locked and limited conversation to collaborators May 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-integrations Issues pertaining to Aspire Integrations packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Projects using Aspire components crash on start if configuration values are missing which is hard to diagnose after deployment

3 participants