Skip to content
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

Fix host process picker when session init'd. #437

Conversation

rkeithhill
Copy link
Contributor

Also fix the "initialConfigurations" attach setting to use the host process picker and set a default runspaceId.

Also fix the "initialConfigurations" attach setting to use the host process picker and set a default runspaceId.
@rkeithhill rkeithhill changed the title Fix host process picker when session init'd. WIP Fix host process picker when session init'd. Jan 16, 2017
@@ -105,7 +114,7 @@ export class PickPSHostProcessFeature implements IFeature {

if (this.waitingForClientToken) {
this.clearWaitingToken();
return this.pickPSHostProcess();
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this still be called so that the menu will be displayed when the connection is finally established?

Copy link
Contributor Author

@rkeithhill rkeithhill Jan 16, 2017

Choose a reason for hiding this comment

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

It will display the UI but the resulting pick is dropped on the floor AFAICT. As I understand it, the whole process operates like so:

  1. User picks attach to in debug panel
  2. Dbg config for attach has ${command.pickPSHostProcess} configured to get the processId value
  3. That command is invoked and in turn, activates PowerShell since it is registered as activation event
  4. When the command completes, VSCode uses the returned string as the processId value. If the command does not return a string, the adapter gets sent "undefined" for processId.

So what I think we need is a synchronization primitive (like *ResetEvent / CriticalSection) so that the command can "wait w/timeout" on the setLanguageClient to signal that it has been initialized.

BTW in the process of debugging this I found a bug (two actually) in VSCode :-) microsoft/vscode#6569 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

BTW if we want to punt on this for 0.9.0, I could return an error message when PowerShell hasn't been started along the lines of "You must start a PowerShell session before using attach to PowerShell host process".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK so reading up some on JavaScript - no need for sync primitives due to single-threaded nature of JavaScript/node. Hmm...

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep you shouldn't need to worry about thread synchronization in JavaScript. If this is good enough for now I'll merge it and then poke around with it a bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, go ahead and merge it and see what you think. Hopefully, you can figure out a better way to handle the PowerShell not initialized case.

Tell user to try again after PowerShell has fully initialized.  This is not an ideal user experience but it is better than the current experience.
@daviwil daviwil changed the title WIP Fix host process picker when session init'd. Fix host process picker when session init'd. Jan 17, 2017
@daviwil
Copy link
Contributor

daviwil commented Jan 17, 2017

Thanks Keith!

@daviwil daviwil merged commit d84582b into PowerShell:master Jan 17, 2017
@rkeithhill rkeithhill deleted the rkeithhill/process-pick-handle-no-selection branch January 18, 2017 01:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants