metals-vscode icon indicating copy to clipboard operation
metals-vscode copied to clipboard

Metals regularly disconnects from build server

Open kylechadha opened this issue 3 years ago • 19 comments

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:

  1. Open an sbt repository, import the build
  2. Everything works great
  3. Laptop sleeps
  4. When I come back, metals features (gotodef etc) do not work
  5. 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

kylechadha avatar Nov 18 '22 19:11 kylechadha

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?

  1. Could you run Run Doctor command and paste that piece of information here? Screenshot 2022-11-19 at 12 15 01
  2. 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 jps to get all java processes
  • sleep
  • wake mac, run jps again to check and compare now vs in the past

kpodsiad avatar Nov 19 '22 11:11 kpodsiad

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?

kylechadha avatar Nov 19 '22 19:11 kylechadha

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)

kpodsiad avatar Nov 22 '22 13:11 kpodsiad

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:

tgodzik avatar Nov 23 '22 13:11 tgodzik