Repository navigation
#1088 Harden coordinator handler registrations - #1090
Merged
Merged
Conversation
Follow-up to #1089, from an independent review. - Handler removal releases the removed closures after the coordinator lock, so a handler whose deinit cancels another registration cannot deadlock. - The registration token is nonisolated and removes entries from the lock-guarded handler storage, but the coordinator itself stays MainActor-inferred: profile-change work and handler delivery must stay on the main thread. A new test asserts a saved handler runs isolated to MainActor. - Add a test that a profile save reuses the root's Home model; it is the invariant #1089 introduced and nothing covered it. - Drop the unused Container.makeProjectListHomeViewModel factory and the 200 ms sleep in the deallocation test.
ivanfenenko
force-pushed
the
fix/1088-registration-hardening
branch
from
November 19, 2026 15:20
b5915b8 to
62207f2
Compare
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
Follow-up to #1089, from an independent review. #1088 stays closed; this hardens what landed.
What changed
Registrationandregistration(removing:)arenonisolated, and the lock-guarded handler arrays arenonisolated(unsafe), so a released token can remove its entry from any thread.ConnectionSessionCoordinatoritself stays MainActor-inferred: an earlier draft marked the whole classnonisolatedand an independent review caught that this moved profile-change work, handler delivery andActiveConnectionManagercalls onto the gate's background executor. The shape here typechecks under both-swift-version 5and-swift-version 6with-default-isolation MainActor.profileSavesDeliverHandlersOnTheMainActorasserts withMainActor.assertIsolated()inside a saved handler. It fails with the broadnonisolatedvariant and passes with this one.deinitcancels another registration cannot re-enter the coordinator's non-recursiveNSLock.AppRootHomeOwnershipTestsprovesenterHome()and a profile save reuse the same Home model; this is the invariant #1088 Keep one Home view model across server switches #1089 introduced and nothing covered it. It waits on the realenterHome → onForeground → startIfConnected → hasActiveConnectionsignal, not a sleep.Container.makeProjectListHomeViewModel()(the last way to build a Home model in abody) and the 200 ms sleep in the deallocation test.Checks
SharedFlowcollectors have no equivalent registration lifetime.ConnectionSessionCoordinatorTests,ProjectListHomeViewModelTests,AppRootHomeOwnershipTests,ActiveConnectionManagerProtocolTests,ServersSwitchTestson the iOS simulator (pass), plus the Swift 5/Swift 6 isolation typechecks.