Stop the git pane's file watch crashing the app - #292
Merged
Conversation
The git pane's FSEvents handler was written inside a `@MainActor` method, so the closure inherited main-actor isolation — and FSEvents calls it on the watcher's own utility queue. The first main-actor touch, filtering build products out of the event batch, hit Swift 6's executor check and took the whole app down with SIGTRAP. It fires whenever files change under a repo with the pane armed, so an agent's edit-build-look loop trips it repeatedly. `FolderEventStream`'s handler is `@Sendable` now, which forbids the silent isolation inheritance: the hop back to the main actor is the caller's explicit job, and forgetting it is a compile error rather than a crash on someone's desk. The pane's path test and its ignored-component set are `nonisolated` — they are pure string work — and the watched paths are captured immutably.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
termio dies with
SIGTRAPwhen files change under a repo whose git pane is armed. Crash reports show the FSEvents callback going throughswift_task_checkIsolated→dispatch_assert_queue_failinGitPanelModel.armWatcher().The handler closure is written inside a
@MainActormethod, so it inherits main-actor isolation.FolderEventStreamruns it on a utility queue, and the first main-actor touch — theisBuildProductEventfilter — trips Swift 6's executor check and kills the process. TheTask { @MainActor }hop at the end of the handler was correct; the work before it was not.Fixing only the one call would leave the trap armed for the next caller, so the fix is at the API boundary:
FolderEventStream's handler is@Sendable, which forbids isolation inheritance outright. That turns the same mistake into a compile error — it produced exactly the two errors this PR fixes, at the crash site.FileTreeWatcher, the other consumer, already delivers on.mainand needed no change.Hit repeatedly today during ordinary rebuilds: an agent's edit-build-look loop writes into the worktree constantly, which is exactly the trigger.
Verification
swift buildclean,swift test243/243. The compiler reproducing the defect is the regression guard — the isolation is now checked at build time rather than asserted at runtime. Not exercised on a running app; the runtime check is to open the Changes pane and write a file into the repo.Release Notes:
Fixed a crash when files changed on disk while the git pane was open.