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

[typescript][electron] Error when trying to start the TS server inside a bundled electron application #1392

Closed
kittaakos opened this issue Feb 27, 2018 · 13 comments
Labels
bug bugs found in the application electron issues related to the electron target typescript issues related to the typescript language

Comments

@kittaakos
Copy link
Contributor

I need to add some error log here which I do not yet have...

@kittaakos kittaakos added bug bugs found in the application electron issues related to the electron target typescript issues related to the typescript language labels Feb 27, 2018
@kittaakos kittaakos self-assigned this Feb 27, 2018
@kittaakos
Copy link
Contributor Author

It will be tough to figure out what is going on. When I start the application with either open /Applications/Theia.app/ or cd /Applications/Theia.app/Contents/MacOS/Theia && ./Theia it works. If I start the application from its application icon from, for instance, Finder, it does not work.

@kittaakos
Copy link
Contributor Author

That's the best trace I have managed to collect after modifying the bundle.js inside the application:
screen shot 2018-02-27 at 14 32 38

@kittaakos
Copy link
Contributor Author

I have this when starting the application from the terminal. I do not know yet whether it is realted to the TS LS issue or not.:

{"name":"Theia","hostname":"Akoss-MBP.fritz.box","pid":51856,"level":50,"msg":"Error: Header must provide a Content-Length property.\n    at StreamMessageReader.onData (/Applications/Theia.app/Contents/Resources/app/node_modules/vscode-jsonrpc/lib/messageReader.js:200:27)\n    at Socket.<anonymous> (/Applications/Theia.app/Contents/Resources/app/node_modules/vscode-jsonrpc/lib/messageReader.js:185:19)\n    at emitOne (events.js:96:13)\n    at Socket.emit (events.js:191:7)\n    at readableAddChunk (_stream_readable.js:178:18)\n    at Socket.Readable.push (_stream_readable.js:136:10)\n    at Pipe.onread (net.js:560:20) []","time":"2018-02-27T13:44:08.070Z","v":0}

@svenefftinge
Copy link
Contributor

Do you open it on a folder that has node_modules/typescript ?

@kittaakos
Copy link
Contributor Author

Great pointer. That could be the difference.

@kittaakos
Copy link
Contributor Author

So for sure, the environment is different from the Theia terminal and outside of Theia:
screen shot 2018-02-27 at 16 02 51

@kittaakos
Copy link
Contributor Author

But, after modifying the typescript-contribution I can print both the TS and Node.js versions. The processConnectionStream object is initialized correctly.

@kittaakos
Copy link
Contributor Author

There is clearly a difference when starting the application from the terminal and from the application "icon".

screen shot 2018-02-27 at 16 53 21

@kittaakos
Copy link
Contributor Author

If I add the typescript dependency to the package.json to make sure typescript is inside the node_modules, I get the following error:

bundle.js:50966 Uncaught (in promise) Error: Request initialize failed with message: Couldn't find 'tsserver' executable
    at new ResponseError (file:///Users/akos.kitta/Desktop/Theia.app/Contents/Resources/app/lib/bundle.js:50966:28)
    at handleResponse (file:///Users/akos.kitta/Desktop/Theia.app/Contents/Resources/app/lib/bundle.js:11804:48)
    at processMessageQueue (file:///Users/akos.kitta/Desktop/Theia.app/Contents/Resources/app/lib/bundle.js:11632:17)
    at Immediate.<anonymous> (file:///Users/akos.kitta/Desktop/Theia.app/Contents/Resources/app/lib/bundle.js:11616:13)
    at runCallback (timers.js:672:20)
    at tryOnImmediate (timers.js:645:5)
    at processImmediate [as _immediateCallback] (timers.js:617:5)

The stack trace is useless, as it is from the browser, but the message says tsserver was not found although it is in under node_modules/typescript/bin. The binary execution inside an ASAR cannot be a problem here.

@svenefftinge
Copy link
Contributor

Here is how the language server looks up the tsserver binary:

https://github.com/theia-ide/typescript-language-server/blob/master/src/lsp-server.ts#L69

For sure, we need to send proper information to the user in case it cannot find it. (see typescript-language-server/typescript-language-server#28)

@kittaakos
Copy link
Contributor Author

Thanks!

I'm afraid this ticket tries to solve multiple problems:

  • I am not sure if stdio can be used for the communication. I shall try with ipc.
  • I will check the binary lookup too.
  • The electron application seems to have different environment when started from command line and application icon. For instance, when started from the icon, node is not available from the terminal. It dies before even starting the TS server.

@kittaakos
Copy link
Contributor Author

Workaround: declare typescript as a dependency in the package.json.

@kittaakos
Copy link
Contributor Author

This has been fixed via #3534. POC: theia-ide/theia-apps#79

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bugs found in the application electron issues related to the electron target typescript issues related to the typescript language
Projects
None yet
Development

No branches or pull requests

2 participants