Metals regularly disconnects from build server
Describe the bug
Each time I come back to my machine after it has gone to sleep, I have to reconnect to the metals build server with Metals: Connect to build server
To Reproduce Steps to reproduce the behavior:
- Open an sbt repository, import the build
- Everything works great
- Laptop sleeps
- When I come back, metals features (gotodef etc) do not work
- Select
Metals: Connect to build server, after a minute things start working again
Expected behavior
Metals would remain connected or auto-reconnect to build server
Installation:
- Operating system: macOS
- VSCode version:
Version: 1.72.2
Commit: d045a5eda657f4d7b676dedbfa7aab8207f8a075
Date: 2022-10-12T22:16:30.254Z (1 mo ago)
Electron: 19.0.17
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Darwin x64 21.6.0
Sandboxed: No
- VSCode extension version: v1.20.0
- Metals version: 0.11.9
Hi @kylechadha, thanks for reporting. I've been using Metals on macOS and I've never encountered such issue. Does it happens always when you follow to reproduce steps? I can think of one thing currently, maybe your mac is killing some background processes before going to sleep?
- Could you run
Run Doctorcommand and paste that piece of information here?
- Could you:
- close all vs code instances, run
killAll java, thanks to that all unwanted processes will be killed - open one repository with vs code
- run
jpsto get all java processes - sleep
- wake mac, run
jpsagain to check and compare now vs in the past
HI @kpodsiad, thanks for taking a look! Glad to hear it's not expected behavior.
Here's the results of metals doctor:
Metals Doctor
Build server currently being used is Bloop v1.5.4.
Metals Java: 1.8.0_265 from Azul Systems, Inc. located at /Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre
Metals Server version: 0.11.9
Performed all the steps in step 2 and see the same results from jps:
➜ home jps
12346 Server
13084 Jps
12221 Main
➜ home jps
13136 Jps
12346 Server
12221 Main
However I noticed in the output tab that the workspace was re-compiled when I came back from sleep. There was a short period of time where gotodef wasn't working, but it's back now, so I guess it doesn't always happen deterministically after sleeping 🤔 .
So perhaps it's some combination of sleep + time passing that results in the process getting killed?
Thing with process being killed was just a guess, because I can't see other reason for disconnecting. @tgodzik me if I'm wrong, but Metals doesn't disconnect from build server without a reason (like explicit command from the user)
Thing with process being killed was just a guess, because I can't see other reason for disconnecting. @tgodzik me if I'm wrong, but Metals doesn't disconnect from build server without a reason (like explicit command from the user)
It doesn't disconnect and should try to connect automatically if there is an exception. If you try manually running clean compile, does anything happen in the logs? I remember there was an issue with some bad state that Metals had, which was preventing things from getting compiled :thinking: