-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Fix ssh terminals #15443
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 ssh terminals #15443
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking into this!
However, I'm not sure this is a good solution to the issue. Is there something wrong with the binaries we're uploading? Can you try using the code from master
and just replace the binaries for node-pty with ones that come with the installation of node-pty
on Windows?
if (backendRemoteService.isRemoteServer()) { | ||
this.spawnFunction = require('./external-node-pty/node-pty').spawn; | ||
} else { | ||
this.spawnFunction = spawn; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: I'm confused as to why this is necessary. Can you expand on that a bit? AFAIK our build shouldn't bundle the JS code differently on Windows compared to Linux. So even if the binaries are different, the JS code shouldn't change.
// ensure the node binary is on path so the node modules are compiled for the correct version | ||
prefix = `export PATH=${nodeBinDir}:$PATH;`; | ||
} | ||
await connection.exec(`${prefix} cd ${libDir}; ${npmExecutable} init -y; ${npmExecutable} install node-pty tslib`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might not work if the remote machine doesn't have a "normal" network connection. I.e. outbound HTTP traffic might be blocked to some degree.
This is a little bit tricky if you look at the way var WindowsPtyAgent = /** @class */ (function () {
function WindowsPtyAgent(file, args, env, cwd, cols, rows, debug, _useConpty, _useConptyDll, conptyInheritCursor) {
var _this = this;
if (_useConptyDll === void 0) { _useConptyDll = false; }
if (conptyInheritCursor === void 0) { conptyInheritCursor = false; }
this._useConpty = _useConpty;
this._useConptyDll = _useConptyDll;
this._pid = 0;
this._innerPid = 0;
if (this._useConpty === undefined || this._useConpty === true) {
this._useConpty = this._getWindowsBuildNumber() >= 18309;
}
if (this._useConpty) {
if (!conptyNative) {
try {
conptyNative = __webpack_require__(Object(function webpackMissingModule() { var e = new Error("Cannot find module '../build/Release/conpty.node'"); e.code = 'MODULE_NOT_FOUND'; throw e; }()));
} That line at the bottom being the problematic one. If we add the All of this is to say, I suspect what you've suggested is doable, but I'm not sure how to. |
Ah, thanks a lot, that explains it well! And thank you for the investigation efforts. Alright, I think that we probably can get a simpler solution by performing a bit of bundler magic in Webpack. I'll prepare something next week 👍 |
Where's this at? Would you like me to look into implementing the idea you described? |
@parisa-mchp I actually created a WIP over at master...msujew/fix-remote-windows-terminals but didn't have time to get back to it (I also currently don't have a setup in which I can easily test this). The change might work out of the box, but it shows the approach how I would fix this. If you have some time to dig into it, please go ahead and continue on my changes :) |
@msujew Thanks so much for providing this. I don't know webpack too well so I would have had a hard time doing this part. From here I think I can get something working. |
28f7bd2
to
29521d1
Compare
@parisa-mchp For some reason, the ECA validation doesn't work correctly with my email in the commit. Feel free to remove my attribution from the commit 👍 |
29521d1
to
23dcb79
Compare
Okay, right now everything seems to be working on my end. As before, I don't have a way to test macos, but every combination of windows and linux I tried seemed okay. As for the test failures, I think there's some kind of outage in one of the servers the plugins are downloaded from. It was working fine earlier today for me, but the |
@parisa-mchp It looks like the Eclipse foundation service infrastructure faces a major outage right now. That's the reason for the failing pipelines. Nothing to worry about :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I'll merge this as soon as the Eclipse foundation outage is fixed (one of the checks is a required check unfortunately).
@msujew Should be good to retrigger now! |
@parisa-mchp Do you mind force pushing to the PR? The GH actions seem to be stuck. |
Signed-off-by: Parisa Betel Miri <parisa.betelmiri@microchip.com>
e002b9c
to
d9f474c
Compare
What it does
This PR addresses an issue where from a linux client connecting to a windows server with by ssh, you cannot open terminals. This is because the node-pty module that we rely on to create terminals is compiled in a platform specific way, so when the node backend is copied onto the server, an incorrect version of node-pty is provided. For some reason, this does not cause issues making the reverse connection, from a windows client to a linux server.
To fix this, we do a webpack exclude so that the node-pty module is resolved at run-time instead of at compile time, and as part of the server setup we install node-pty so a correct version will be available for the server's platform. We don't exclude node-pty when not connected to a server. Otherwise, additional care would need to be taken when creating a theia extension to ensure any generated appimages include the node-pty module, and that a remote, which would then have two copies of the module, resolve the correct one.
How to test
To reproduce the issue, connect from a linux client to a windows server, and attempt to open an ide terminal. Any other client-server combination should still work. I have tested linux-linux, linux-windows, windows-linux, and windows-windows, but have don't have access to any systems running macos. When connecting to a server twice with different builds, make sure to delete the
.theia-example-electron-1.60.0-remote
folder.Follow-ups
The current implementation is somewhat complex. Suggestions would be appreciated, but at the moment I don't see a way to simplify it.
Breaking changes
Attribution
Review checklist
Reminder for reviewers