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 #59635 #60111

Merged
merged 3 commits into from
Dec 13, 2018
Merged

Fix #59635 #60111

merged 3 commits into from
Dec 13, 2018

Conversation

g-arjones
Copy link
Contributor

@g-arjones g-arjones commented Oct 7, 2018

@Tyriar AFAICT, the process Id promise resolver is invalidated once the process id is set.

Please let me know if there is a problem with this...

Fix #59635

@g-arjones g-arjones force-pushed the fix_terminal_process_id branch from f9835ad to 0ce9601 Compare October 9, 2018 04:09
@@ -772,6 +774,8 @@ export class TerminalInstance implements ITerminalInstance {
this._processManager.onProcessExit(exitCode => this._onProcessExit(exitCode));
this._processManager.onProcessData(data => this._onData.fire(data));

this._onProcessLaunching.fire(this);
Copy link
Member

Choose a reason for hiding this comment

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

I think the ID may not be ready at this time (race condition), this._processManager.onProcessReady should instead be used as the new ID will definitely be set:

https://github.com/Microsoft/vscode/blob/cbd629998bdcc07bd4f98ecc3721b27a20317ec9/src/vs/workbench/parts/terminal/electron-browser/terminalProcessManager.ts#L130-L131

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I don't get your point. I am not setting nor using the process id here. This onProcessLaunching event is fired just so that the terminal instance can create the promise and store the resolver which can be done as soon as a new process request is received. Or am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In fact, this used to be done in the terminal's constructor...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

/cc @Tyriar

Copy link
Member

Choose a reason for hiding this comment

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

+1 to using onProcessReady to ensure that the ID is already set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm obviously missing the point here. I mean, onProcessLaunching signals that a new process will be launched whereas onProcessIdReady signals that the process DID launch. They serve different purposes in my opinion.

Besides, why have these events nested? If onProcessLaunching is going to be fired by onProcessIdReady isn't it more sensible to just create the process Id promise in onProcessIdReady anyway?

Could you please elaborate on that just for the sake of clarity?

Copy link
Member

Choose a reason for hiding this comment

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

You're using the event and then passing in instance

https://github.com/Microsoft/vscode/pull/60111/files#diff-738f70b1596a3687ce11b464cd29bfc2R283

That event listener then uses instance.id:

https://github.com/Microsoft/vscode/pull/60111/files#diff-fef4270273da47cf116c1d80fe3da649R38

This is what we're concerned about, instance.id may still be out of date but it wouldn't be if this._processManager.onProcessReady was used instead to fire the original event.

Copy link
Contributor Author

@g-arjones g-arjones Oct 15, 2018

Choose a reason for hiding this comment

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

@Tyriar Hmmm.. But isn't that the terminal instance id (rather than the process id) ? The terminal instance id is set in its constructor here:

https://github.com/Microsoft/vscode/blob/0ce96012870c5364eb143c62b9fcce56fcdfecf8/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts#L142

And should not depend on the process id being set and is never changed/updated. Is that correct?

@Tyriar Tyriar requested a review from alexr00 October 11, 2018 18:11
@Tyriar Tyriar added this to the October 2018 milestone Oct 11, 2018
Copy link
Member

@alexr00 alexr00 left a comment

Choose a reason for hiding this comment

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

+1 to using onProcessReady to ensure that the ID is already set.

@Tyriar Tyriar modified the milestones: October 2018, Backlog Oct 25, 2018
@g-arjones
Copy link
Contributor Author

@Tyriar Could you clarify, please?

@g-arjones
Copy link
Contributor Author

Some feedback would be highly appreciated...

@Tyriar Tyriar force-pushed the fix_terminal_process_id branch from 65d98c0 to e6254db Compare December 13, 2018 18:02
@Tyriar Tyriar modified the milestones: Backlog, December 2018 Dec 13, 2018
Copy link
Member

@Tyriar Tyriar left a comment

Choose a reason for hiding this comment

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

@g-arjones thanks for the investigation and the great repro, they were very useful to get to the bottom of this. I ended up coming with a simpler fix to just recreate the promiseId using the existing mechanism. And sorry about the delay, I was out all November. 😃

@Tyriar Tyriar merged commit bf15510 into microsoft:master Dec 13, 2018
@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Terminal.processId property is not updated once terminal's process is changed
3 participants