Skip to content

Workaround "attach to process" hang #846

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 11, 2019
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/PowerShellEditorServices/Session/RunspaceDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,11 @@ internal static RunspaceDetails CreateFromRunspace(
defaultValue: string.Empty);

// hostname is 'ServerRemoteHost' when the user enters a session.
// ex. Enter-PSSession, Enter-PSHostProcess
if (hostName.Equals("ServerRemoteHost", StringComparison.Ordinal))
// ex. Enter-PSSession
// Attaching to process currently needs to be marked as a local session
// so we skip this if block if the runspace is from Enter-PSHostProcess
if (hostName.Equals("ServerRemoteHost", StringComparison.Ordinal)
&& runspace.OriginalConnectionInfo.GetType().ToString() != "System.Management.Automation.Runspaces.NamedPipeConnectionInfo")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be a good idea to do a null check here. I think there are a couple ConnectionInfo's that do not get written here but are still ServerRemoteHost

Suggested change
&& runspace.OriginalConnectionInfo.GetType().ToString() != "System.Management.Automation.Runspaces.NamedPipeConnectionInfo")
&& runspace.OriginalConnectionInfo != null
&& runspace.OriginalConnectionInfo.GetType().ToString() != "System.Management.Automation.Runspaces.NamedPipeConnectionInfo")

Copy link
Member Author

@TylerLeonhardt TylerLeonhardt Jan 10, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better yet:

runspace.OriginalConnectionInfo?.GetType().ToString() != "System.Management.Automation.Runspaces.NamedPipeConnectionInfo"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops! Got stuck in bool mode and had it in my head you'd have to do ?? false. Nice catch :)

{
runspaceLocation = RunspaceLocation.Remote;
connectionString =
Expand Down