Repository navigation
Give the startup checks a scope of their own - #80
Merged
Merged
Conversation
Umbraco resolves notification handlers from a scope that ends once the notification is handled, but the startup checks run on in the background. When that scope ended first, resolving FlagDiagnostics threw ObjectDisposedException, so the checks never ran and every start logged a warning. The checks now take an IServiceScopeFactory and create a scope that lasts as long as they do. Fixes #78
Member
Author
Review: ready to mergeReviewed at What I checked
Fine to merge. |
This was referenced Nov 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Umbraco resolves notification handlers from a scope that ends once the notification has been handled.
StartupChecksstarts its checks in a background task and returns, so the checks could start after that scope had gone. ResolvingFlagDiagnosticsfrom the handler'sIServiceProviderthen threwObjectDisposedException. The checks never ran, and every start logged a warning.It's a race, so it shows on some machines and not others. The demo site here never logged it, while the reporter saw it on every start.
HandleAsyncreadsIRuntimeStateandIHostApplicationLifetimethrough a short scope of its own too, so nothing in the class depends on the handler's scope.The 17.x, 18.x and 19.x packages are built from this same source, so the fix applies to all three.
Evidence
The_checks_still_run_after_the_scope_the_handler_came_from_has_ended: it ends the handler's scope before the checks run, so the order is certain rather than a race. The checks still run and report what they find, with no "couldn't run its startup checks" warning.ObjectDisposedExceptiononce the handler's scope has ended. That's the exception in the issue.Merge danger
Two-way door.
StartupChecksis internal, so its constructor isn't public API. There are no settings or behaviour changes, except that the checks now run at startup as intended. Sites that set something up wrongly will start seeing the errors and warnings these checks were always meant to log.Closes #78