fix: run WorkspaceService PSCommands on the pipeline thread#4
Merged
dkattan merged 1 commit intoJul 11, 2026
Merged
Conversation
InvokePSCommand executes on the calling thread against the shared runspace, so calling it from LSP handler threads violated runspace thread affinity. Route EnumeratePSFiles and GetContent through the pipeline thread task queue unless already on it. Also broaden the ObjectNotFound catch in GetContent so non-FileSystem providers, which report the missing path as a plain string instead of a string[], surface FileNotFoundException like the FileSystem provider. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
InvokePSCommandexecutes on the calling thread against the shared runspace, so calling it from LSP handler threads violated runspace thread affinity.EnumeratePSFilesandGetContentinWorkspaceServicenow route through a newExecutePSCommandOnPipelineThreadhelper that queues onto the pipeline thread viaExecutePSCommandAsyncunless the caller is already on it (guarded by a new internalPsesInternalHost.IsPipelineThreadproperty, which prevents self-deadlock when blocking on the queued task).ObjectNotFoundcatch inGetContent: the FileSystem provider reports missing paths asstring[], but other providers report a plainstring, so their misses previously leaked out as rawActionPreferenceStopExceptioninstead ofFileNotFoundException.Why
Needed for PSPath-backed script files in ImmyBot (feat/pspath-script-provider). Reading workspace files through a custom PSProvider from LSP request threads intermittently corrupted the runspace due to the thread-affinity violation. Once merged, ImmyBot bumps the editor services package to preview.6 built from
feature/get-content-host-package.Testing
Verified against a live ImmyBot session: PSPath-backed files load through
GetContentfrom LSP handler threads without runspace errors, and missing PSPath files surface asFileNotFoundExceptionmatching FileSystem behavior.🤖 Generated with Claude Code