Smarthome: [lsp] Exiting vscode causes openHAB java process to exit

Created on 28 Sep 2018  路  17Comments  路  Source: eclipse-archived/smarthome

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

What I鈥檓 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鈥檓 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鈥檓 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.

Most helpful comment

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

All 17 comments

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.

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 :-/

FTR: Running

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

from Oracle on a Mac.

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

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).

Might be related to this discussion: https://github.com/eclipse/lsp4j/issues/161
Sounds like a feature, not a bug 馃槦

Sounds like a feature

Oh my! :-o

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

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: https://github.com/eclipse/xtext-core/commit/27bd8abb0d78cfbd201a48a940617b85fa84bf67#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.

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

FTR, I have created https://github.com/openhab/openhab-core/pull/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.

@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!

@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.

@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

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!

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

@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!

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.

Was this page helpful?
0 / 5 - 0 ratings