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

Self-hosting does not work on Windows in Electron mode #6846

Closed
westbury opened this issue Jan 8, 2020 · 10 comments · Fixed by #10518
Closed

Self-hosting does not work on Windows in Electron mode #6846

westbury opened this issue Jan 8, 2020 · 10 comments · Fixed by #10518
Labels
electron issues related to the electron target OS/Windows issues related to the Windows OS

Comments

@westbury
Copy link
Contributor

westbury commented Jan 8, 2020

Description

Plugin self-hosting does not work in the Electron version on Windows. #6316 fixes it on Windows for the browser version but does not address the separate issue on Electron.

Reproduction Steps

Clone https://github.com/tom-shan/theia-plugin-hello-world.
Build (yarn) theia-plugin-hello-world.
Open Theia on theia-plugin-hello-world.
Hosted Plugin: Start Instance.
Nothing happens.

This problem occurs only when both Windows and Electron.

Diagnostics:

This problem was originally discovered by @kittaakos

#6316 (comment)

@sboudreaux96
Copy link

sboudreaux96 commented May 18, 2021

Hello all - I am still having this same problem and am looking for a fix. anyone have any recommendations?

@vince-fugnitto
Copy link
Member

Hello all - I am still having this same problem and am looking for a fix. anyone have any recommendations?

@sboudreaux96 I do not believe there is a fix yet for theia-plugins on electron.
Alternatively you can write a vscode extension and consume it in your theia-based electron application

@Tom-Yucw
Copy link
Contributor

Tom-Yucw commented Dec 6, 2021

Hi, all, is this problem solved? I still failed to start self-hosting plugin on windows10 by

  1. using yo @theia/plugin to make a Hello World plug-in
  2. adding "@types/node": "12.20.0" in package.json to avoid error "node_modules@types\node\assert.d.ts"
  3. run yarn to build plugin
  4. run "Hosted Plug-in: Start Instence" in command, and select the source dir which includes file package.json

Nothing happens except

  1. a "Host Plugin: Starting" status showed in the left-bottom
  2. showed "Starting hosted instance server..." notification

@Tom-Yucw
Copy link
Contributor

Tom-Yucw commented Dec 7, 2021

Finally, I debugged the problem, and by referring to [https://github.com/nodejs/node/issues/3675], added an option in function runHostedPluginTheiaInstance in file packages\plugin-dev\src\node\hosted-plugins-manager.ts to fix this.
This problem did not happen on Ubuntu 18.04, so I used a judgement of OS.
Code is showed as follows.

 import * as os from 'os';
 ......
  protected runHostedPluginTheiaInstance(command: string[], options: cp.SpawnOptions): Promise<URI> {
       this.isPluginRunning = true;
       return new Promise((resolve, reject) => {
           let started = false;
           const outputListener = (data: string | Buffer) => {
               const line = data.toString();
               const match = THEIA_INSTANCE_REGEX.exec(line);
               if (match) {
                   this.hostedInstanceProcess.stdout!.removeListener('data', outputListener);
                   started = true;
                   resolve(new URI(match[1]));
               }
           };

           try {
               const os_type_str = os.type().toLowerCase();
               if (os_type_str.indexOf('windows') >= 0) {
                   options['shell'] = true;
               }
           } catch (error) {
               console.log(error);
           }

           this.hostedInstanceProcess = cp.spawn(command.shift()!, command, options);
           this.hostedInstanceProcess.on('error', () => { this.isPluginRunning = false; });
           this.hostedInstanceProcess.on('exit', () => { this.isPluginRunning = false; });
           this.hostedInstanceProcess.stdout!.addListener('data', outputListener);
           ......

@msujew
Copy link
Member

msujew commented Dec 7, 2021

@Tom-Yucw Thank you for looking into it 👍

You can simplify the try-catch block into this, removing the need for the os import:

if (isWindows) { // Imported from "@theia/core"
   options.shell = true;
}

Are you interested in providing a pull request for this? This is probably the fastest way someone will look into this :)

@Tom-Yucw
Copy link
Contributor

Tom-Yucw commented Dec 7, 2021

@Tom-Yucw Thank you for looking into it 👍

You can simplify the try-catch block into, removing the need for the os import:

if (isWindows) { // Imported from "@theia/core"
   options.shell = true;
}

Are you interested in providing a pull request for this? This is probably the fastest way someone will look into this :)

OK, thanks for your advice. I tried your method, it works well.
I will make a pull request later. This is my first time to do this, so excited!

@msujew
Copy link
Member

msujew commented Dec 7, 2021

@Tom-Yucw Great, please don't forget to sign the eclipse contributor agreement (eca) with the same email as your contribution (your commit email). Doing this after creating the pull request might lead to some complications in the review process :)

@Tom-Yucw
Copy link
Contributor

Tom-Yucw commented Dec 8, 2021

Hi, msujew, I have signed the eca, but failed to set reviewer. A review required after I made a pull request. Would you please help me to do a review?

@msujew
Copy link
Member

msujew commented Dec 8, 2021

@Tom-Yucw That's alright, contributors who aren't members of the Theia team can't request reviewers themselves. The team will take a look when time allows.

@Tom-Yucw
Copy link
Contributor

Tom-Yucw commented Dec 8, 2021

@Tom-Yucw That's alright, contributors who aren't members of the Theia team can't request reviewers themselves. The team will take a look when time allows.

OK
Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
electron issues related to the electron target OS/Windows issues related to the Windows OS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants