René's URL Explorer Experiment


Title: Remote PSSession disconnects after launch debugging session ends · Issue #2263 · PowerShell/PowerShellEditorServices · GitHub

Open Graph Title: Remote PSSession disconnects after launch debugging session ends · Issue #2263 · PowerShell/PowerShellEditorServices

X Title: Remote PSSession disconnects after launch debugging session ends · Issue #2263 · PowerShell/PowerShellEditorServices

Description: Prerequisites I have written a descriptive issue title. I have searched all open and closed issues to ensure it has not already been reported. I have read the troubleshooting guide. I am sure this issue is with PowerShell Editor Services...

Open Graph Description: Prerequisites I have written a descriptive issue title. I have searched all open and closed issues to ensure it has not already been reported. I have read the troubleshooting guide. I am sure this ...

X Description: Prerequisites I have written a descriptive issue title. I have searched all open and closed issues to ensure it has not already been reported. I have read the troubleshooting guide. I am sure this ...

Opengraph URL: https://github.com/PowerShell/PowerShellEditorServices/issues/2263

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Remote PSSession disconnects after launch debugging session ends","articleBody":"### Prerequisites\n\n- [x] I have written a descriptive issue title.\n- [x] I have searched all [_open and closed_ issues](https://github.com/PowerShell/PowerShellEditorServices/issues?q=is%3Aissue) to ensure it has not already been reported.\n- [x] I have read the [troubleshooting](https://github.com/PowerShell/vscode-powershell/blob/main/docs/troubleshooting.md) guide.\n- [x] I am sure this issue is with _PowerShell Editor Services itself_ and does not reproduce in a standalone [PowerShell](https://github.com/PowerShell/PowerShell/issues/new/choose) instance, and is not an issue with my editor.\n- [x] I have verified that I am using the latest version of PowerShell Editor Services.\n- [x] If this is a security issue, I have read the [security issue reporting guidance](https://github.com/PowerShell/vscode-powershell/blob/main/SECURITY.md).\n\n### Summary\n\nWhen using remote PowerShell debugging from VS Code server (Linux → Windows over PSSession over SSH) with a launch configuration and path mappings, the remote PSSession unexpectedly drops immediately after the debug session finishes. As soon as any command is run post-debugging, the user gets kicked back to the local session.\n\n### Technical Analysis\n\nAfter investigating the PowerShellEditorServices codebase, I traced the issue through this execution flow:\n\n1. **Launch sessions never set `ExecutionCompleted = true` when they finish normally.** Unlike Attach sessions (which set this via `OnExecutionCompletedAsync` in `LaunchAndAttachHandler.cs:493`), Launch sessions execute via `ConfigurationDoneHandler.LaunchScriptAsync()` which has no equivalent completion handler.\n\n2. When the debug session ends, `DisconnectHandler` checks `ExecutionCompleted` (`DisconnectHandler.cs:55-58`)\n\n3. Because `ExecutionCompleted` is still `false`, it calls `_debugService.Abort()`\n\n4. `Abort()` calls `SetDebugResuming(DebuggerResumeAction.Stop)` (`PowerShellDebugContext.cs:97`)\n\n5. `SetDebugResuming()` calls `_psesHost.SetExit()` (`PowerShellDebugContext.cs:115`)\n\n6. `SetExit()` sets `_shouldExit = true` on the remote frame when it's a REPL with multiple frames (`PsesInternalHost.cs:360-371`)\n\n7. The next time the run loop executes (`RunExecutionLoop`, around line 917), it sees `_shouldExit == true` for a remote, non-nested REPL frame and calls `PopPowerShell()` (`PsesInternalHost.cs:917-922`)\n\n8. `PopPowerShell()` pops the remote REPL frame and detects the runspace change, which causes it to pop from `_runspaceStack`, exiting the PSSession (`PsesInternalHost.cs:763-790`)\n\n### Root Cause\n\nLaunch sessions do not set `ExecutionCompleted = true` when the debugged script finishes. This causes `DisconnectHandler` to treat a normal completion as an abort scenario, calling `Abort()` which ultimately sets `_shouldExit = true` on the remote REPL frame, causing the PSSession to exit.\n\n### Proposed Fix\n\nSet `ExecutionCompleted = true` in `ConfigurationDoneHandler.LaunchScriptAsync()` after script execution completes:\n\n```csharp\nawait _executionService.ExecutePSCommandAsync(\n    command,\n    CancellationToken.None,\n    s_debuggerExecutionOptions).ConfigureAwait(false);\n\n// Fix: Mark execution as completed for launch sessions\nif (_debugStateService is not null)\n{\n    _debugStateService.ExecutionCompleted = true;\n}\n\n_debugAdapterServer?.SendNotification(EventNames.Terminated);\n```\n\nThis aligns the behavior of Launch sessions with Attach sessions, which already set this flag in `OnExecutionCompletedAsync`.\n\n\n### PowerShell Version\n\n```console\n$PSVersionTable        \n\nName                           Value\n----                           -----\nPSVersion                      7.5.4\nPSEdition                      Core\nGitCommitId                    7.5.4\nOS                             Rocky Linux 8.10 (Green Obsidian)\nPlatform                       Unix\nPSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}\nPSRemotingProtocolVersion      2.3\nSerializationVersion           1.1.0.1\nWSManStackVersion              3.0\n```\n\n### Editor Version\n\n```console\nemacs --version\n\nGNU Emacs 30.1.90\n```\n\n### PowerShell Editor Services Version\n\n```console\n$pseditor.EditorServicesVersion\n\nMajor  Minor  Build  Revision\n-----  -----  -----  --------\n4      4      0      0\n```\n\n### Steps to Reproduce\n\n**Steps to Reproduce**\n\nSet up VS Code server on Linux\nConfigure launch debugging with path mappings\nEstablish remote PSSession to Windows machine over SSH\nSet breakpoint\nStart a launch-based debug session\nLet the debug session complete normally\nRun any command in the remote session\nObserve that the PSSession drops and returns to local session\n**Expected Behavior**\nThe remote PSSession should remain active after a launch debug session completes, allowing continued work in the remote context.\n\n**Actual Behavior**\nThe remote PSSession drops immediately after the first command is run following debug session completion.\n\n### Visuals\n\n_No response_\n\n### Logs\n\n_No response_","author":{"url":"https://github.com/alexmet82","@type":"Person","name":"alexmet82"},"datePublished":"2025-12-01T16:18:43.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/2263/PowerShellEditorServices/issues/2263"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:e8094a2c-faef-b51b-11f7-baac0b3c1000
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE70C:372616:492875F:672C0FE:6A56F751
html-safe-noncea6dbcf96f600abd88c71f40fd26f444f463b66e47e7feea88350ca9d747c7e28
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNzBDOjM3MjYxNjo0OTI4NzVGOjY3MkMwRkU6NkE1NkY3NTEiLCJ2aXNpdG9yX2lkIjoiNzYwMDg4ODY4MTkyNDUwMzg1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac8fdb2f9992b153b3c3b189bb1c6c7479287bda8c711742e9f113f6103cb3d1fd
hovercard-subject-tagissue:3681766624
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShellEditorServices/2263/issue_layout
twitter:imagehttps://opengraph.githubassets.com/9ec01be7e3e69402b2f30deeefffa3b9190a5d8a9ed494d5d36a1c177794e4d7/PowerShell/PowerShellEditorServices/issues/2263
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/9ec01be7e3e69402b2f30deeefffa3b9190a5d8a9ed494d5d36a1c177794e4d7/PowerShell/PowerShellEditorServices/issues/2263
og:image:altPrerequisites I have written a descriptive issue title. I have searched all open and closed issues to ensure it has not already been reported. I have read the troubleshooting guide. I am sure this ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamealexmet82
hostnamegithub.com
expected-hostnamegithub.com
None4eb29e5f807bd95e41196adfbc6d28f9af12d89830d8b684f3e871774ddff2fc
turbo-cache-controlno-preview
go-importgithub.com/PowerShell/PowerShellEditorServices git https://github.com/PowerShell/PowerShellEditorServices.git
octolytics-dimension-user_id11524380
octolytics-dimension-user_loginPowerShell
octolytics-dimension-repository_id36031537
octolytics-dimension-repository_nwoPowerShell/PowerShellEditorServices
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id36031537
octolytics-dimension-repository_network_root_nwoPowerShell/PowerShellEditorServices
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releaseb056788a129fb0194b61f2ebb4c43f6a9f4dfd27
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/PowerShell/PowerShellEditorServices/issues/2263#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPowerShellEditorServices%2Fissues%2F2263
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPowerShellEditorServices%2Fissues%2F2263
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=PowerShell%2FPowerShellEditorServices
Reloadhttps://github.com/PowerShell/PowerShellEditorServices/issues/2263
Reloadhttps://github.com/PowerShell/PowerShellEditorServices/issues/2263
Reloadhttps://github.com/PowerShell/PowerShellEditorServices/issues/2263
Please reload this pagehttps://github.com/PowerShell/PowerShellEditorServices/issues/2263
PowerShell https://github.com/PowerShell
PowerShellEditorServiceshttps://github.com/PowerShell/PowerShellEditorServices
Notifications https://github.com/login?return_to=%2FPowerShell%2FPowerShellEditorServices
Fork 260 https://github.com/login?return_to=%2FPowerShell%2FPowerShellEditorServices
Star 759 https://github.com/login?return_to=%2FPowerShell%2FPowerShellEditorServices
Code https://github.com/PowerShell/PowerShellEditorServices
Issues 127 https://github.com/PowerShell/PowerShellEditorServices/issues
Pull requests 14 https://github.com/PowerShell/PowerShellEditorServices/pulls
Actions https://github.com/PowerShell/PowerShellEditorServices/actions
Security and quality 0 https://github.com/PowerShell/PowerShellEditorServices/security
Insights https://github.com/PowerShell/PowerShellEditorServices/pulse
Code https://github.com/PowerShell/PowerShellEditorServices
Issues https://github.com/PowerShell/PowerShellEditorServices/issues
Pull requests https://github.com/PowerShell/PowerShellEditorServices/pulls
Actions https://github.com/PowerShell/PowerShellEditorServices/actions
Security and quality https://github.com/PowerShell/PowerShellEditorServices/security
Insights https://github.com/PowerShell/PowerShellEditorServices/pulse
Remote PSSession disconnects after launch debugging session endshttps://github.com/PowerShell/PowerShellEditorServices/issues/2263#top
Issue-BugA bug to squash.https://github.com/PowerShell/PowerShellEditorServices/issues?q=state%3Aopen%20label%3A%22Issue-Bug%22
Needs: TriageMaintainer attention needed!https://github.com/PowerShell/PowerShellEditorServices/issues?q=state%3Aopen%20label%3A%22Needs%3A%20Triage%22
https://github.com/alexmet82
alexmet82https://github.com/alexmet82
on Dec 1, 2025https://github.com/PowerShell/PowerShellEditorServices/issues/2263#issue-3681766624
open and closed issueshttps://github.com/PowerShell/PowerShellEditorServices/issues?q=is%3Aissue
troubleshootinghttps://github.com/PowerShell/vscode-powershell/blob/main/docs/troubleshooting.md
PowerShellhttps://github.com/PowerShell/PowerShell/issues/new/choose
security issue reporting guidancehttps://github.com/PowerShell/vscode-powershell/blob/main/SECURITY.md
Issue-BugA bug to squash.https://github.com/PowerShell/PowerShellEditorServices/issues?q=state%3Aopen%20label%3A%22Issue-Bug%22
Needs: TriageMaintainer attention needed!https://github.com/PowerShell/PowerShellEditorServices/issues?q=state%3Aopen%20label%3A%22Needs%3A%20Triage%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.