fix(macos): capture weak self in network-monitor Task#19
Merged
Conversation
The NWPathMonitor update handler captures [weak self], making self a
mutable weak var. Referencing it from the nested Task { @mainactor }
trips strict-concurrency checking ('reference to captured var self in
concurrently-executing code'), which a newer Swift toolchain on the CI
runner image promoted from a warning to a hard error, breaking the
release build.
Give the Task its own [weak self] capture so it holds an immutable copy
instead of the outer closure's captured var.
Bump the single source of truth (root package.json) and the three lockstep sources the release workflow validates — core and cli package.json versions and the macOS app's CFBundleShortVersionString — to 5.0.1.
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.
Why
The release build's Build (Swift) step started failing with a hard compile error:
In
startNetworkMonitor(), theNWPathMonitorupdate handler captures[weak self], which makesselfa mutableweak var. Referencing it from the nestedTask { @MainActor }trips strict-concurrency checking. A newer Swift toolchain on the CI runner image (macos-14-arm6420260525.0091) promoted this from a warning to a hard error, breaking the release build. (The same pattern in theDispatchQueue.asyncclosures elsewhere in the file stays a warning for now.)Fix
Give the
Taskits own[weak self]capture so it holds an immutable copy instead of referencing the outer closure's capturedvar self:Verification
swift build --package-path apps/macos— completes cleanlyswift test --package-path apps/macos— all 15 tests pass