Bicep extension crashes with "Connection closed", or fails to activate with "Couldn't create connection to server"
- Dominant language
- Bicep
- Stars
- 3.6k
- Forks
- 830
- Avg merge
- 1d 21m
- Merged PRs (30d)
- 79
Description
This error occurs whenever our language server unexpectedly crashes or fails to launch. There can be many possible causes, so this issue exists to aggregate the known ones along with troubleshooting steps.
## Known possible causes
1. If you've configured `dotnetAcquisitionExtension.existingDotnetPath`, you're fixing yourself to a particular version of dotnet and **will** be broken **every time** Bicep upgrades to a later version.
* Try removing this setting and re-launching VSCode.
1. If you're running VSCode Devcontainers via Docker on an M1 Mac, you **must** be using Rosetta2 emulation, and not qemu.
* The simplest way to ensure this is by ensuring you are using Docker v4.25.0 or higher.
1. AppLocker blocks the `dotnet` executable on Windows.
* Look at Event Viewer for AppLocker blocks to validate the theory. Additional Information for Event viewer: https://learn.microsoft.com/en-us/windows/security/threat-protection/windows-defender-application-control/applocker/using-event-viewer-with-applocker.
* Can be mitigated by configuring `dotnetAcquisitionExtension.existingDotnetPath` with a known good copy of dotnet.
## If you see a new case
To help us debug:
1. Include the full "Bicep" output window contents when you report the issue.
1. Search the output window for the two lines containing "Found dotnet command at" and "Found language server at" - e.g.
```
2023-03-24T13:19:02.735Z debug: Found dotnet command at '/Users/ant/Library/Application Support/Code/User/globalStorage/ms-dotnettools.vscode-dotnet-runtime/.dotnet/7.0.4/dotnet'.
2023-03-24T13:19:02.735Z debug: Found language server at '/Users/ant/.vscode/extensions/ms-azuretools.vscode-bicep-0.15.120-gf1c10aa51f/bicepLanguageServer/Bicep.LangServer.dll'.
```
1. If you're able to obtain the dotnet & dll path from the previous step, try running the same command in a Terminal window. If you see any error information when running this, please include this with your comment.
## Related issues
- #10113
- #10240
- #9665
- #3117
- #5141
- #626
- #10099
- #5514
## Examples of errors
### Activation
```
Action: bicep.activate
Error type: UNKNOWN
Error Message: spawn UNKNOWN
Version: 0.15.31
OS: win32
OS Release: 10.0.22621
Product: Visual Studio Code
Product Version: 1.76.1
Language: en
```
Call Stack
```
extension.js:2:2290600extension.js:2:2290600
async LanguageClient.createConnection extension.js:2:2114731
async LanguageClient.start extension.js:2:2105146
extension.js:2:3473325extension.js:2:3473325
```
### Crash
```
Action: bicep.lsp-error
Error type: Error
Error Message: Connection closed
Version: 0.13.1
OS: win32
OS Release: 10.0.19044
Product: Visual Studio Code
Product Version: 1.71.0
Language: en
```
Call Stack
```
new AppInsightsAsyncCorrelatedErrorWrapper applicationinsights/CorrelationContextManager.js:172:18
extension.js:2:2994407extension.js:2:2994407
callWithTelemetryAndErrorHandlingSync extension.js:2:715923
Object.closed extension.js:2:2994315
LanguageClient.handleConnectionClosed extension.js:2:2029143
LanguageClient.handleConnectionClosed extension.js:2:2197757
extension.js:2:2028833extension.js:2:2028833
CallbackList.invoke extension.js:2:1975662
Emitter.fire extension.js:2:1976450
closeHandler extension.js:2:1960921
CallbackList.invoke extension.js:2:1975662
Emitter.fire extension.js:2:1976450
SocketMessageWriter.fireClose extension.js:2:1988090
Socket. extension.js:2:1988901
ZoneDelegate.invokeTask zone.js/zone-node.js:275:35
Zone.runTask zone.js/zone-node.js:151:47
ZoneTask.invoke zone.js/zone-node.js:345:33
```
Contributor guide
Research direction
The issue names no repository files or tests. Start by reviewing the documented causes, output-window diagnostics, and related issues (#10113, #10240, #9665, #3117, #5141, #626, #10099, #5514); done would require an explicitly scoped documentation or diagnostic change, which the payload does not provide.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, vscode
- Domain
- devtools, documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100