mill
mill copied to clipboard
Issues with BSP `workspace/reload`
So after playing around a fair bit with mill-bsp
it seems that the reload functionality isn't quite working as I originally thought it does. It's a bit decieving since according to here:
https://github.com/com-lihaoyi/mill/blob/c3b64a54be184d9d41b219d84761479dd61f10af/bsp/src/mill/bsp/MillBuildServer.scala#L303-L313
It doesn't do anything but send back an {}
. Metals then interprets this as a successful reload and moves on, when really this may not be a successful reload. You can can see this for example if you misspell something like tesFrameworks
and hit save. Metals will prompt you to re-import with under the hood triggers a workspace/reload
to which Mill immediately returns {}
making metals think everything is ok. If I remember the conversation correctly the idea was the shut down and restart, but that also doesn't fully seem to be happening when looking at the bsp logs after a reload.
For example if I edit the build.sc
with something invalid and trigger a reload I'll see this:
[Trace - 11:02:13 PM] Sending request 'workspace/reload - (14)'
Params: null
[Trace - 11:02:13 PM] Received response 'workspace/reload - (14)' in 2ms
Result: {}
Error: null
[Trace - 11:02:14 PM] Sending request 'buildTarget/scalaMainClasses - (15)'
Reload happens, Metals is happy and then Mill starts answers the requests for the main classes and tests classes. It doesn't seem to shut down and it's actually in a somewhat invalid state where the build is invalid, but Metals is still working off the last working state. I've also seen this cause you to get into a loop where you close the project, and then the next time you attempt to re-open it fails to get any build targets, and then re-initializes over and over.
2021.11.29 23:06:41 INFO Attempting to connect to the build server...
2021.11.29 23:06:41 INFO tracing is enabled: /Users/ckipp/Documents/scala-workspace/mill-minimal/.metals/bsp.trace.json
2021.11.29 23:06:40 WARN No build session currently active to reload.
2021.11.29 23:06:41 INFO time: Connected to build server in 0.91s
2021.11.29 23:06:41 INFO Connected to Build server: mill-bsp v0.10.0-M4
2021.11.29 23:06:47 INFO tracing is enabled: /Users/ckipp/Documents/scala-workspace/mill-minimal/.metals/bsp.trace.json
2021.11.29 23:06:47 INFO Connected to Build server: mill-bsp v0.10.0-M4
2021.11.29 23:06:49 INFO no build target: using presentation compiler with only scala-library: 2.13.7
2021.11.29 23:06:49 INFO time: code lens generation in 3.77s
2021.11.29 23:06:51 INFO no build target: using presentation compiler with only scala-library: 2.13.7
2021.11.29 23:06:52 INFO tracing is enabled: /Users/ckipp/Documents/scala-workspace/mill-minimal/.metals/bsp.trace.json
2021.11.29 23:06:52 INFO Connected to Build server: mill-bsp v0.10.0-M4
2021.11.29 23:06:56 INFO shutting down Metals
2021.11.29 23:06:56 INFO Shut down connection with build server.
2021.11.29 23:06:56 INFO Disconnecting from mill-bsp session...
Here are some more bsp trace files showing this:
BSP TRACE
[Trace - 11:06:41 PM] Sending request 'build/initialize - (1)'
Params: {
"rootUri": "file:///Users/ckipp/Documents/scala-workspace/mill-minimal/",
"displayName": "Metals",
"version": "0.10.9+80-6ff28e97-SNAPSHOT",
"bspVersion": "2.0.0-M15",
"capabilities": {
"languageIds": [
"scala"
]
},
"data": {
"semanticdbVersion": "4.4.30",
"supportedScalaVersions": [
"2.13.7",
"2.12.15",
"2.12.14",
"2.12.13",
"2.12.12",
"2.12.11",
"2.13.4",
"2.13.5",
"2.13.6",
"2.11.12",
"2.12.8",
"2.12.9",
"2.12.10",
"2.13.0",
"2.13.1",
"2.13.2",
"2.13.3"
]
}
}
[Trace - 11:06:42 PM] Received response 'build/initialize - (1)' in 836ms
Result: {
"displayName": "mill-bsp",
"version": "0.10.0-M4",
"bspVersion": "2.0.0",
"capabilities": {
"compileProvider": {
"languageIds": [
"java",
"scala"
]
},
"testProvider": {
"languageIds": [
"java",
"scala"
]
},
"runProvider": {
"languageIds": [
"java",
"scala"
]
},
"debugProvider": {
"languageIds": []
},
"inverseSourcesProvider": true,
"dependencySourcesProvider": true,
"dependencyModulesProvider": true,
"resourcesProvider": true,
"buildTargetChangedProvider": false,
"canReload": true
}
}
Error: null
[Trace - 11:06:42 PM] Sending notification 'build/initialized'
Params: null
[Trace - 11:06:42 PM] Sending request 'workspace/buildTargets - (2)'
Params: null
[Trace - 11:06:47 PM] Sending request 'build/initialize - (1)'
Params: {
"rootUri": "file:///Users/ckipp/Documents/scala-workspace/mill-minimal/",
"displayName": "Metals",
"version": "0.10.9+80-6ff28e97-SNAPSHOT",
"bspVersion": "2.0.0-M15",
"capabilities": {
"languageIds": [
"scala"
]
},
"data": {
"semanticdbVersion": "4.4.30",
"supportedScalaVersions": [
"2.13.7",
"2.12.15",
"2.12.14",
"2.12.13",
"2.12.12",
"2.12.11",
"2.13.4",
"2.13.5",
"2.13.6",
"2.11.12",
"2.12.8",
"2.12.9",
"2.12.10",
"2.13.0",
"2.13.1",
"2.13.2",
"2.13.3"
]
}
}
[Trace - 11:06:47 PM] Received response 'build/initialize - (1)' in 697ms
Result: {
"displayName": "mill-bsp",
"version": "0.10.0-M4",
"bspVersion": "2.0.0",
"capabilities": {
"compileProvider": {
"languageIds": [
"java",
"scala"
]
},
"testProvider": {
"languageIds": [
"java",
"scala"
]
},
"runProvider": {
"languageIds": [
"java",
"scala"
]
},
"debugProvider": {
"languageIds": []
},
"inverseSourcesProvider": true,
"dependencySourcesProvider": true,
"dependencyModulesProvider": true,
"resourcesProvider": true,
"buildTargetChangedProvider": false,
"canReload": true
}
}
Error: null
[Trace - 11:06:47 PM] Sending notification 'build/initialized'
Params: null
[Trace - 11:06:50 PM] Sending request 'workspace/buildTargets - (2)'
Params: null
[Trace - 11:06:52 PM] Sending request 'build/initialize - (1)'
Params: {
"rootUri": "file:///Users/ckipp/Documents/scala-workspace/mill-minimal/",
"displayName": "Metals",
"version": "0.10.9+80-6ff28e97-SNAPSHOT",
"bspVersion": "2.0.0-M15",
"capabilities": {
"languageIds": [
"scala"
]
},
"data": {
"semanticdbVersion": "4.4.30",
"supportedScalaVersions": [
"2.13.7",
"2.12.15",
"2.12.14",
"2.12.13",
"2.12.12",
"2.12.11",
"2.13.4",
"2.13.5",
"2.13.6",
"2.11.12",
"2.12.8",
"2.12.9",
"2.12.10",
"2.13.0",
"2.13.1",
"2.13.2",
"2.13.3"
]
}
}
[Trace - 11:06:53 PM] Received response 'build/initialize - (1)' in 753ms
Result: {
"displayName": "mill-bsp",
"version": "0.10.0-M4",
"bspVersion": "2.0.0",
"capabilities": {
"compileProvider": {
"languageIds": [
"java",
"scala"
]
},
"testProvider": {
"languageIds": [
"java",
"scala"
]
},
"runProvider": {
"languageIds": [
"java",
"scala"
]
},
"debugProvider": {
"languageIds": []
},
"inverseSourcesProvider": true,
"dependencySourcesProvider": true,
"dependencyModulesProvider": true,
"resourcesProvider": true,
"buildTargetChangedProvider": false,
"canReload": true
}
}
Error: null
[Trace - 11:06:53 PM] Sending notification 'build/initialized'
Params: null
Thanks for the nice report. This looks like a duplicate of #1560.
Thanks for the nice report. This looks like a duplicate of #1560.
Ahh sorry, I totally missed that one. Since there is quite a bit of info in here I'll leave it up, but if you prefer I an also just port this all over there.