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

Creating a terminal in a basic (Hello World) Theia app hangs the app #12733

Open
jcortell68 opened this issue Jul 19, 2023 · 19 comments
Open

Creating a terminal in a basic (Hello World) Theia app hangs the app #12733

jcortell68 opened this issue Jul 19, 2023 · 19 comments
Labels
OS/Windows issues related to the Windows OS 🤔 needs more info issues that require more info from the author

Comments

@jcortell68
Copy link
Contributor

jcortell68 commented Jul 19, 2023

Bug Description:

A basic Theia app hangs when you try to create a terminal on Windows...but only if you launch the app via the VS Code launch configuration.

git clone -b master https://github.com/jcortell68/theiasandbox
cd theiasandbox
yarn
yarn rebuild:electron
code .
  1. In VS Code, launch the Theia app using Start Electron Backend. Don't start a debug session; use Run Without Debugging
  2. Create a terminal via Terminal > New Terminal
    Note that a terminal seems to appear (without a prompt) but the Theia app/UI is completely hung at that point.

Interestingly, the problem does not happen if you launch the app from the terminal using yarn start:electron

Additional Information

  • Operating System: Windows
  • Theia Version: 1.39
@vince-fugnitto
Copy link
Member

It seems to work fine both when I generate a new hello-world app, or yours (I am on Linux) however.
Could it be caused by #12734 instead?

@vince-fugnitto vince-fugnitto added the OS/Windows issues related to the Windows OS label Jul 20, 2023
@jcortell68
Copy link
Contributor Author

jcortell68 commented Jul 20, 2023

12734 is a separate issue that I opened; I very much doubt they are related (other than they might both be Windows-only issues)

Let me try on Linux. This could be a Windows-only issue.

@jcortell68
Copy link
Contributor Author

Yeah. Works fine for me on Linux. We'll need someone else to try on Windows and see if it's a "me" issue or a general one.

@vladarama
Copy link
Contributor

vladarama commented Jul 20, 2023

@jcortell68
I just tried reproducing the bug on Windows and everything seems to work fine.
Demo:
terminal hanging

@jcortell68
Copy link
Contributor Author

@vladarama Thanks. That got me thinking. I tried to reproduce the issue, but this time closed the workspace in the Theia app. Sure enough, it works now. I tried opening a different workspace. Still works. So I'm guessing there was something funky in the workspace that Theia was opening earlier. Unfortunately, I don't remember what directory that was. But needless to say, we can close this ticket. Thanks guys!

@jcortell68
Copy link
Contributor Author

@vince-fugnitto BTW, I retried 12734 and that one is still reproducible. So confirmed that issue and this one are unrelated.

@jcortell68
Copy link
Contributor Author

jcortell68 commented Jul 20, 2023

Uh oh. The plot thickens. The hang suddenly and unexpectedly started happening for me, and without being able to workaround it by closing the workspace. After a lot of head-scratching, I realized what was going on. The problem reproduced for me only when I launch the app via the VS Code's launch configuration (Start Electron Backend). Note that I launch it using Run Without Debugging

If I launch the app at the terminal using yarn start:electron, then the problem doesn't reproduce.

@vladarama Can you try using the launch configuration? Curious to see if you reproduce the issue that way.

@vladarama
Copy link
Contributor

Yeah, I can confirm the bug is present on Windows when launching electron from VS Code's launch config.
Demo:
terminal hanging

@jcortell68
Copy link
Contributor Author

Thanks for confirming! I'll adjust the ticket title and description and reopen it

@jcortell68 jcortell68 reopened this Jul 21, 2023
@jcortell68
Copy link
Contributor Author

@vladarama Quick side question: what tool do you use to create your GIF screen recordings?

@vladarama
Copy link
Contributor

@jcortell68
I use LICEcap for the GIF recordings:
https://www.cockos.com/licecap/

@vince-fugnitto
Copy link
Member

@jcortell68 I believe the issue is pretty specific to the theia-extension-generator (might even be fixed by eclipse-theia/generator-theia-extension#173).

Also note that the .vscode/launch.json you have in your repository does not work (@vladarama had to modify jcortell68/theiasandbox@6ed8dd5), and the steps you highlighted to reproduce are incomplete (yarn is not sufficient before starting to debug with start without debugging).

@jcortell68
Copy link
Contributor Author

@vince-fugnitto Yeah. I just realized the issues with the setup a little while ago. I tried building from a fresh git clone and ran into them. I'm sorting that out now. But I don't think the issue is fixed by the pull request you mention, as I have that change in other branches in my repo and I think I can reproduce the problem there. Anyway, let me clean this all up and I'll post and update here shortly

@jcortell68
Copy link
Contributor Author

jcortell68 commented Jul 21, 2023

OK. I've pushed a new commit which resolves all the setup issues. I also added a missing step in the description that only made itself obvious in a clean environment (I added yarn rebuild:electron)

I git clone'd to a new location and tested the reproducibility steps. Everything went smooth, and the problem still reproduces.

I can also confirm it reproduces only on Windows.

@Gerd-Augsburg
Copy link

I have a very different environment, but the exact same Problem.
I build the Docker Container from: https://github.com/eclipse-theia/theia-blueprint
If i try to open a terminal in the browser, the backend hangs.
No Error, just not responsive anymore.

If i restart the backend and open with a browser that "remembers" the open terminal tab i see a warning in the Logs:
"terminal WARN Couldn't attach - can't find terminal with id: -1"
and the backend immediately hangs again.

Not sure if realated or complete different Problem.

@jcortell68
Copy link
Contributor Author

@Gerd-Augsburg That second scenario also happens for me in the Electron case. I.e., if when I launch the app, it already has a terminal open, then the app hangs right away. I suspect we are running into the same underlying problem.

@Gerd-Augsburg
Copy link

An update:
The underlying problem might be the same (i assume it can't open a new tty) but the reason for it on my side is Docker.
Local without container it works fine and running the container as a pod in a kubernetes cluster works too.
Only Docker run doesn't work.
If someone knows the docker setting i am missing, it would be nice to know, but here is not the place for docker questions.
So for this thread my problem is not existent any more.

@martin-fleck-at
Copy link
Contributor

martin-fleck-at commented Aug 10, 2023

So I debugged into this on Windows and I believe we are a victim of this bug: microsoft/node-pty#532. If I manually pause before line

const connect = (this._ptyNative as IConptyNative).connect(this._pty, commandLine, cwd, env, c => this._$onProcessExit(c));

during debugging then everything works. It seems that there is something not ready yet to connect but I couldn't find any stack trace or error.

I tried several versions to see if the problem might be resolved in any of them:

Unfortunately, for me they all have the same issue so I think we may need to wait for this bug to be fixed on the node-pty side or we could try to artifically introduce some delay somehow.

@jcortell68
Copy link
Contributor Author

jcortell68 commented Aug 10, 2023

Nice sleuthing. It's unfortunate that node-pty ticket was opened 18 months ago and has had no meaningful activity. I guess waiting it out is reasonable given that it's a bit of a specialized scenario (hang happens on Windows only, only if launched via VS Code launch config, only when opening a terminal). I guess if we see more people pile on to this ticket, we can consider an ugly sleep hack. Thanks for investigating this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS/Windows issues related to the Windows OS 🤔 needs more info issues that require more info from the author
Projects
None yet
Development

No branches or pull requests

5 participants