Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

[lsp] Exiting vscode causes openHAB java process to exit #6291

Closed
mhilbush opened this issue Sep 28, 2018 · 17 comments · Fixed by openhab/openhab-core#742
Closed

[lsp] Exiting vscode causes openHAB java process to exit #6291

mhilbush opened this issue Sep 28, 2018 · 17 comments · Fixed by openhab/openhab-core#742

Comments

@mhilbush
Copy link
Contributor

mhilbush commented Sep 28, 2018

See discussion here.
https://community.openhab.org/t/lsp-in-vs-code-causes-openhab-restart/52439/5

What I’m seeing on OH build 1372 is that the openHAB Java process exits silently when VS Code is closed, or when you close the conf folder in VS Code (which likely has the same effect as closing VS Code).

I’m not seeing this behavior on 1368.

I put the following LSP bundles in TRACE mode to see if I could capture indication of what might be happening. Nothing was logged when I exited VS Code .

 94 x Active   x  80 x 0.4.1.v20180515-1321   x org.eclipse.lsp4j
 95 x Active   x  80 x 0.4.1.v20180515-1321   x org.eclipse.lsp4j.jsonrpc
129 x Active   x  80 x 0.10.0.201809210646    x org.eclipse.smarthome.model.lsp

In the interest of full disclosure, I’m running OpenJDK.

openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-8u181-b13-0ubuntu0.16.04.1-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)

Edit: I'm seeing this on three different OH installations, all of which are running 1372 or later.

@kaikreuzer
Copy link
Contributor

Java process exits silently

What does that exactly mean? Afaik, Java only exists silently, if System.exit() is called - in the case of a crash, it will rather log some crash dump message.

@kaikreuzer
Copy link
Contributor

Uh, wow, I can indeed reproduce it. Not by closing VSCode (openHAB keeps running), but by closing the folder in VS Code. Indeed, a sudden death :-/

@kaikreuzer
Copy link
Contributor

FTR: Running

Java(TM) SE Runtime Environment (build 1.8.0_161-b12)

from Oracle on a Mac.

@mhilbush
Copy link
Contributor Author

Right, in my case, either closing the folder, or exiting VS Code causes the issue.

@mhilbush
Copy link
Contributor Author

It truly is silent. Nothing logged in any of the OH log files, nothing in syslog, and nothing logged to stdout (when run from a shell using start.sh).

@kaikreuzer
Copy link
Contributor

Might be related to this discussion: eclipse-lsp4j/lsp4j#161
Sounds like a feature, not a bug 😟

@mhilbush
Copy link
Contributor Author

mhilbush commented Sep 28, 2018

Sounds like a feature

Oh my! :-o

Edit: That code snippet in the issue you referenced certainly explains why it's silent...

@MHerbst
Copy link
Contributor

MHerbst commented Sep 30, 2018

I had a look into the code of org.eclipse.xtext.ide.server.LanguageServerImpl and the exit() method contains calls to System.exit().
The coding has been added about a year ago with this commit: eclipse/xtext-core@27bd8ab#diff-0fc0eb4aab841adf6e1c198a00c6e95d

This implementation follows the LSP specification of the "exit" request (https://microsoft.github.io/language-server-protocol/specification#exit):

A notification to ask the server to exit its process.

@kaikreuzer
Copy link
Contributor

I have created eclipse/xtext-core#885 for discussion and will check out if I can find a workaround for the time being.

@kaikreuzer
Copy link
Contributor

FTR, I have created openhab/openhab-core#409, which works around the issue in my tests. Not 100% sure it works in all cases as I also saw once a message in VS Code after re-connecting that the LSP server cannot respond as it is being shut down (since according to the spec this is a two step process (shutdown->exit)). I could not reproduce it again, though, so let's first try our luck with that workaround.

@mhilbush
Copy link
Contributor Author

mhilbush commented Oct 8, 2018

@kaikreuzer I see more people reporting "random OH restarts", which could be caused by the xtext issue referenced above. It looks like openHAB core hasn't been built in a while. As it contains your workaround to this issue, could you kick off a build of openHAB core so that it gets included in the next OH build? Thanks!

@kaikreuzer
Copy link
Contributor

@mhilbush It is already included in the snapshot since a few days - it is built with openhab-bundles build, openhab-core build plan is not needed.

@meingraham
Copy link

@kaikreuzer,

I updated to SNAPSHOT 2.4.0~20181001112604-1 (Build #1378) on October 2. Does this build contain the work-around for the VS Code "exit" issue? I can report that with this OH build, when I exit VS Code, OH goes through a hard restart.

I'm also dealing with MQTTITUDE having been moved to legacy status in the 2.4.0M4 milestone. I have not had time yet to migrate to using GPSTracker... so I need to continue using MQTTITUDE for the time being. According to what I read, to continue to use this OH1 binding, I had to add it to addons.cfg. The problem is, when OH stops (as when VS Code causes if to "crash"), all of my bindings get uninstalled (I found this - https://community.openhab.org/t/reinstall-bindings-after-restart-oh2/18945/6). So, the VS Code issue is really painful.

Of course, if I'm doing something wrong (either with VS Code or with OH1 bindings), I'm WIDE open to being steered in the right direction ;-)

Regards.

Mike

@kaikreuzer
Copy link
Contributor

Does this build contain the work-around for the VS Code "exit" issue? I can report that with this OH build, when I exit VS Code, OH goes through a hard restart.

Then it does not contain it ;-) Afaik, it's only included in builds from Oct 2 onwards.

Wrt mqttitude, please do not go off-topic here, but rather ask those questions at https://community.openhab.org/. Thanks!

@meingraham
Copy link

meingraham commented Oct 15, 2018

Afaik, it's only included in builds from Oct 2 onwards

This post, dated Oct. 1 is the reason I wasn't sure if I had a "late enough" build. I guess by the time your workaround was reviewed and merged, the workaround didn't make it until and October 2 build. I was trying to avoid an OH restart (i.e., going through a SNAPSHOT update) due to the OH1 binding issue.

Wrt mqttitude, please do not go off-topic here

I was more mentioning it because of the extent of the problem the VS Code issue is causing... but yes, I was fishing for a resolution ;-) I'll post over on the OH Community ;-)

Regards.

Mike

@radokristof
Copy link

radokristof commented Oct 18, 2018

@kaikreuzer Can you provide me some info when a new testing release will be released? I'm using the Milestone builds and I don't want to change to snapshots.

Thanks!

@mhilbush
Copy link
Contributor Author

I see the long-term fix has been added to xtext-core, and is in the 2.16.0.M3 release.

I don't know when the final 2.16.0 release is planned, but hopefully the timing will work out and the next openHAB xtext upgrade will pick this up.

wborn added a commit to wborn/openhab-core that referenced this issue Apr 17, 2019
Xtext 2.17 allows for configuring the LanguageServer exit behavior so the SecurityManager workaround can be removed.

Fixes: eclipse-archived/smarthome#6291
Undos: openhab#409

See also:
* "Configurable Server Exit Behavior" in the Xtext 2.16.0 release notes:
  https://www.eclipse.org/Xtext/releasenotes.html#/releasenotes/2018/12/04/version-2-16-0
* eclipse/xtext-core#885

Signed-off-by: Wouter Born <github@maindrain.net>
maggu2810 pushed a commit to openhab/openhab-core that referenced this issue Apr 17, 2019
Xtext 2.17 allows for configuring the LanguageServer exit behavior so the SecurityManager workaround can be removed.

Fixes: eclipse-archived/smarthome#6291
Undos: #409

See also:
* "Configurable Server Exit Behavior" in the Xtext 2.16.0 release notes:
  https://www.eclipse.org/Xtext/releasenotes.html#/releasenotes/2018/12/04/version-2-16-0
* eclipse/xtext-core#885

Signed-off-by: Wouter Born <github@maindrain.net>
splatch pushed a commit to ConnectorIO/copybara-hab-core that referenced this issue Jul 11, 2023
Xtext 2.17 allows for configuring the LanguageServer exit behavior so the SecurityManager workaround can be removed.

Fixes: eclipse-archived/smarthome#6291
Undos: openhab#409

See also:
* "Configurable Server Exit Behavior" in the Xtext 2.16.0 release notes:
  https://www.eclipse.org/Xtext/releasenotes.html#/releasenotes/2018/12/04/version-2-16-0
* eclipse/xtext-core#885

Signed-off-by: Wouter Born <github@maindrain.net>
GitOrigin-RevId: fb972f3
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants