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

Remove ProcessTaskRunner.findCommand, introduce process "started" event #3843

Merged
merged 1 commit into from
Feb 14, 2019

Conversation

simark
Copy link
Contributor

@simark simark commented Dec 14, 2018

In the long term goal of handling properly shell tasks (allowing the
user to specify "abc && def" as the command), we need to get rid of the
findCommand method in ProcessTaskRunner. Otherwise, it will always
return that the binary "abc && def" can't be found. Even for non-shell
tasks, it doesn't seem ideal to implement ourselves the logic of looking
through PATH. It's better to leave that to the OS.

Instead, we want to rely on the underlying thing we use to run processes
(either node's child_process or node-pty) to return us an appropriate
error code.

With node's child_process, we can do it out-of-the-box. With node-pty,
we use our own fork available at [1] which adds the necessary
features. On error, the Process emits an onError event.

For the non-error case, we need to know when the process has been
successfully started, so we can inform the client that the task has been
successfully started. To do this, I added an 'onStart' event on
Process.

[1] https://github.com/theia-ide/node-pty/tree/theia

Change-Id: Ie2db8909610129842912d312872a48aef3de23a5
Signed-off-by: Simon Marchi [email protected]

@simark
Copy link
Contributor Author

simark commented Dec 14, 2018

Not quite ready for review, I need to investigate the failing tests (unless you want to comment on the general approach).

Copy link
Member

@paul-marechal paul-marechal left a comment

Choose a reason for hiding this comment

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

LGTM! But it seems like it broke the terminal tests.

@simark simark force-pushed the simark/process-start-event branch 3 times, most recently from a0d44a4 to 8bc7593 Compare December 17, 2018 21:30
@paul-marechal
Copy link
Member

paul-marechal commented Dec 21, 2018

Still some errors on Windows:

  TerminalProcess
    1) test error on non existent path
    2) test error on trying to execute a directory
    √ test exit (141ms)
    √ test pipe stream (62ms)

@akosyakov
Copy link
Member

Do we really want to support our version of node-pty? Is it temporary? Is there a PR against node-pty to introduce this feature? Do we need CQ for our version?

// cc @svenefftinge @marcdumais-work

@simark
Copy link
Contributor Author

simark commented Jan 3, 2019

Do we really want to support our version of node-pty? Is it temporary? Is there a PR against node-pty to introduce this feature? Do we need CQ for our version?

Hopefully it is temporary. Once we confirmed that the approach works well, I would try to get the functionality merged upstream.

@elaihau elaihau force-pushed the simark/process-start-event branch 2 times, most recently from 08b3cf2 to b18d327 Compare January 3, 2019 20:13
@akosyakov
Copy link
Member

@simark just fyi: I usually test an idea early with upstream, i.e. open an issue or a PR with proposed approach and ask whether it is a right way doing it

@simark
Copy link
Contributor Author

simark commented Jan 4, 2019

@simark just fyi: I usually test an idea early with upstream, i.e. open an issue or a PR with proposed approach and ask whether it is a right way doing it

Ah I just remembered: we (at Ericsson) don't have the approval to sign the Microsoft CLA, so we can't contribute to upstream node-pty... otherwise I would have opened a PR already.

@marcdumais-work could give more details.

@elaihau elaihau force-pushed the simark/process-start-event branch 2 times, most recently from f9d843b to 1738cc8 Compare January 8, 2019 16:44
@simark simark force-pushed the simark/process-start-event branch from 1738cc8 to 3a1026c Compare January 8, 2019 22:02
@simark
Copy link
Contributor Author

simark commented Jan 9, 2019

It looks like the only errors remaining on AppVeyor are the "standard" ones, so this PR is ready to be reviewed.

@simark simark force-pushed the simark/process-start-event branch from 3a1026c to f6fdf27 Compare January 21, 2019 19:31
@simark
Copy link
Contributor Author

simark commented Jan 21, 2019

Ping.

@akosyakov
Copy link
Member

Ah I just remembered: we (at Ericsson) don't have the approval to sign the Microsoft CLA, so we can't contribute to upstream node-pty... otherwise I would have opened a PR already.

Opening a PR does not require signing anything. You can also then say the same on the PR and ask maintainers to land it as own.

@simark
Copy link
Contributor Author

simark commented Jan 22, 2019

Opening a PR does not require signing anything. You can also then say the same on the PR and ask maintainers to land it as own.

I don't think that is how it works. Signing a CLA usually means "I confirm I wrote this code, I confirm I own the rights on it, I confirm I have the right to license it with license X". That is used to protect the project from merging code that shouldn't be merged. The Microsoft people can't just take my code and merge it themselves if I didn't sign the CLA, because that would infringe their own CLA (they don't own that code).

@marcdumais-work
Copy link
Contributor

Signing a CLA usually means "I confirm I wrote this code, I confirm I own the rights on it, I confirm I have the right to license it with license X"

+1. This is very similar how we require that the Eclipse ECA be signed before we merge a contribution. True, one does not need to sign the CLA to submit a PR, but it's needed before it can be ("legally"/"safely") merged.

@akosyakov
Copy link
Member

@simark @marcdumais-work Can they have a look at PR, say yes it is real issue, we cannot merge your PR, but we will fix it in our way without copying your code? The point is that patching some library without bringing an issue to original maintainers is not very sustainable. They can say as well it is not an issue, you should do in this way or it should be fixed differently. At least opening an issue and hearing opinion of maintainers would be good.

@simark
Copy link
Contributor Author

simark commented Jan 25, 2019

@simark @marcdumais-work Can they have a look at PR, say yes it is real issue, we cannot merge your PR, but we will fix it in our way without copying your code? The point is that patching some library without bringing an issue to original maintainers is not very sustainable. They can say as well it is not an issue, you should do in this way or it should be fixed differently. At least opening an issue and hearing opinion of maintainers would be good.

Ok, I opened this:

microsoft/node-pty#265

In the long term goal of handling properly shell tasks (allowing the
user to specify "abc && def" as the command), we need to get rid of the
findCommand method in ProcessTaskRunner.  Otherwise, it will always
return that the binary "abc && def" can't be found.  Even for non-shell
tasks, it doesn't seem ideal to implement ourselves the logic of looking
through PATH.  It's better to leave that to the OS.

Instead, we want to rely on the underlying thing we use to run processes
(either node's child_process or node-pty) to return us an appropriate
error code.

With node's child_process, we can do it out-of-the-box.  With node-pty,
we use our own fork available at [1] which adds the necessary
features.  On error, the Process emits an onError event.

For the non-error case, we need to know when the process has been
successfully started, so we can inform the client that the task has been
successfully started.  To do this, I added an 'onStart' event on
Process.

[1] https://github.com/theia-ide/node-pty/tree/theia

Change-Id: Ie2db8909610129842912d312872a48aef3de23a5
Signed-off-by: Simon Marchi <[email protected]>
@simark simark force-pushed the simark/process-start-event branch from f6fdf27 to b174794 Compare January 28, 2019 17:08
@simark
Copy link
Contributor Author

simark commented Jan 28, 2019

We will try to push again internally to get permission to contribute to node-pty. Can we merge this in the mean time?

@simark
Copy link
Contributor Author

simark commented Feb 11, 2019

Ping.

Copy link
Member

@paul-marechal paul-marechal left a comment

Choose a reason for hiding this comment

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

LGTM, does anyone see anything?

@marcdumais-work
Copy link
Contributor

We will try to push again internally to get permission to contribute to node-pty. Can we merge this in the mean time?

I do not have good confidence that we will get internal permission to contribute this patch to the upstream project. But we should still proceed I think, even if it's not ideal. It's possible that someone will fix the upstream issue Simon opened, at which point we could switch back to the official node-pty.

Do we need CQ for our version?

Technically yes but practically we already have the "NPM production dependencies" CQ that's under review for another PR / branch; we would need to wait until it unblocks before registering a new one for this PR here. If we skip, the new dependency here will be looked-at as part of the next such CQ, which should get opened right after the current one is approved.

@paul-marechal
Copy link
Member

@akosyakov do you have anything against this change?

I mean that we still cannot contribute to Microsoft, and no one wants to pick up @simark's patch to node-pty...

Development on node-pty is rather slow, and shouldn't conflict with what we added, so it would only take a few rebase here and there. I can do it, other members of our team can do it. It can be as easy as bringing up an issue in the tracker to ask for an uplift.

@marcdumais-work
Copy link
Contributor

@marechal-p I think we can proceed - we will need this for tasks to be compatible with vscode.

Copy link
Member

@paul-marechal paul-marechal left a comment

Choose a reason for hiding this comment

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

LGTM, works nicely!

@simark simark merged commit f24de1c into master Feb 14, 2019
@simark
Copy link
Contributor Author

simark commented Feb 14, 2019

Thanks Paul!

@simark simark deleted the simark/process-start-event branch February 14, 2019 16:32
@simark
Copy link
Contributor Author

simark commented Feb 14, 2019

Oops, I should have done a manual rebase and re-test, this causes is a build error. I'll take a look.

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.

4 participants