Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LSP Server doesn't seem to respond after format request sent - hangs after: Sending notification 'textDocument/didChange'. #297

Closed
jingo64 opened this issue Aug 22, 2023 · 1 comment
Labels
triage-needed Issue is not triaged.

Comments

@jingo64
Copy link

jingo64 commented Aug 22, 2023

Hi!

My Black extension appears to be running "correctly", i.e. if I manually run the LSP server I don't see any errors, and if I manually call the "format document" function within VS Code it formats correctly, however when the on-save functionality isn't working as expected which I believe is down to the LSP server that runs the extension failing to respond with anything.

I'm trying to get my Black extension working, our environment is:

  • I'm on a Windows 11 machine running VS Code
  • The code/intepreter runs on an Ubuntu machine which I'm connecting to via Remote-SSH

My local configuration is below (the commented out ones just show various combinations of configuration I've unsuccessfully tried.

    "[python]": {
        "editor.defaultFormatter": "ms-python.black-formatter",
        "editor.formatOnSave": true
    },
    "python.formatting.provider": "none",
    "black-formatter.trace": "trace",
    // "editor.defaultFormatter": null,
    "black-formatter.interpreter": [
        "/home/dmeadows/.local/lint_env/bin/python"
    ],
    // "black-formatter.path": [
    //     "python", "-m", "black"
    // ],
    // "black-formatter.importStrategy": "fromEnvironment",
    
}

A few things I've tried:

  • Explicitly setting the black path
  • Explicitly setting the interpreter path
  • Setting the Python interpreter in VS Code to point at my desired interpreter and omitted the various black options
  • Set the importStrategy both ways

The output from my black extension log is pretty long so I've attached it here, the key thing is it reaches the point where it sends the format request to the LSP server, and nothing is received back:

2023-08-22 10:49:57.211 [info] [Trace - 10:49:57 AM] Sending notification 'textDocument/didChange'.
2023-08-22 10:49:57.211 [info] Params: {
    "textDocument": {
        "uri": "file:///home/dmeadows/code/phoenix/phoenix/table.py",
        "version": 113
    },
    "contentChanges": [
        {
            "range": {
                "start": {
                    "line": 14,
                    "character": 0
                },
                "end": {
                    "line": 14,
                    "character": 0
                }
            },
            "rangeLength": 0,
            "text": "\n"
        }
    ]
}

black extension output.txt

I'm a bit stumped how to proceed, I've started adding random debug symbols into the lsp_server.py file just to see if its actually getting the message. I checked the Extension Host logs, nothing really of interest shows there

2023-08-22 10:48:33.661 [trace] ExtHostCommands#executeCommand setContext
2023-08-22 10:48:33.661 [trace] ExtHostCommands#executeCommand _setContext
2023-08-22 10:48:33.663 [trace] CommandsConverter#DISPOSE _json.showAssociatedSchemaList/295
2023-08-22 10:48:33.665 [trace] CommandsConverter#CREATE _json.showAssociatedSchemaList _json.showAssociatedSchemaList/296
2023-08-22 10:48:33.709 [trace] ExtHostCommands#executeCommand setContext
2023-08-22 10:48:33.710 [trace] ExtHostCommands#executeCommand _setContext
2023-08-22 10:48:33.751 [trace] [DiagnosticCollection] change many (extension, owner, uris) ms-python.python python [[{"$mid":1,"fsPath":"remoteexthost","external":"output:remoteexthost","path":"remoteexthost","scheme":"output"},[]]]
2023-08-22 10:48:33.753 [trace] [DiagnosticCollection] change many (extension, owner, uris) ms-python.python python [[{"$mid":1,"fsPath":"remoteexthost","external":"output:remoteexthost","path":"remoteexthost","scheme":"output"},[]]]
2023-08-22 10:48:33.801 [trace] ExtHostCommands#executeCommand setContext
2023-08-22 10:48:33.801 [trace] ExtHostCommands#executeCommand _setContext
2023-08-22 10:48:40.778 [trace] [DiagnosticCollection] change many (extension, owner, uris) ms-python.python python [[{"$mid":1,"fsPath":"/settings/user","external":"vscode://schemas/settings/user","path":"/settings/user","scheme":"vscode","authority":"schemas"},null]]
2023-08-22 10:48:40.782 [trace] [DiagnosticCollection] change many (extension, owner, uris) vscode.json-language-features _generated_diagnostic_collection_name_#2 [[{"$mid":1,"fsPath":"/home/dmeadows/code/phoenix/.vscode/settings.json","external":"file:///home/dmeadows/code/phoenix/.vscode/settings.json","path":"/home/dmeadows/code/phoenix/.vscode/settings.json","scheme":"file"},[{"startLineNumber":6,"startColumn":5,"endLineNumber":6,"endColumn":41,"message":"This setting will soon be deprecated. Please use the Autopep8 extension or the Black Formatter extension. Learn more here: https://aka.ms/AAlgvkb.","code":"2","severity":4,"modelVersionId":414}]]]
2023-08-22 10:48:40.828 [trace] ExtHostCommands#executeCommand setContext
2023-08-22 10:48:40.828 [trace] ExtHostCommands#executeCommand _setContext
2023-08-22 10:48:40.871 [trace] [DiagnosticCollection] change many (extension, owner, uris) ms-python.python python [[{"$mid":1,"fsPath":"/settings/user","external":"vscode://schemas/settings/user","path":"/settings/user","scheme":"vscode","authority":"schemas"},[]]]
2023-08-22 10:48:40.897 [trace] [DiagnosticCollection] change many (extension, owner, uris) ms-python.python python [[{"$mid":1,"fsPath":"/settings/user","external":"vscode://schemas/settings/user","path":"/settings/user","scheme":"vscode","authority":"schemas"},[]]]
2023-08-22 10:48:40.901 [trace] ExtHostCommands#$executeContributedCommand black-formatter.restart
2023-08-22 10:48:40.902 [trace] [DiagnosticCollection] remove all (extension, owner) ms-python.black-formatter _generated_diagnostic_collection_name_#41
2023-08-22 10:48:40.933 [trace] ExtHostCommands#executeCommand setContext
2023-08-22 10:48:40.933 [trace] ExtHostCommands#executeCommand _setContext
2023-08-22 10:48:41.078 [trace] [DiagnosticCollection] change many (extension, owner, uris) vscode.json-language-features _generated_diagnostic_collection_name_#2 [[{"$mid":1,"fsPath":"c:/Users/dmeadows/AppData/Roaming/Code/User/settings.json","external":"vscode-userdata:/c%3A/Users/dmeadows/AppData/Roaming/Code/User/settings.json","path":"/C:/Users/dmeadows/AppData/Roaming/Code/User/settings.json","scheme":"vscode-userdata"},[]]]
2023-08-22 10:48:41.128 [trace] ExtHostCommands#executeCommand setContext
2023-08-22 10:48:41.128 [trace] ExtHostCommands#executeCommand _setContext
2023-08-22 10:48:41.400 [trace] [DiagnosticCollection] change many (extension, owner, uris) ms-python.python python [[{"$mid":1,"fsPath":"/ignoredSettings","external":"vscode://schemas/ignoredSettings","path":"/ignoredSettings","scheme":"vscode","authority":"schemas"},null]]
2023-08-22 10:48:41.404 [trace] [DiagnosticCollection] change many (extension, owner, uris) vscode.json-language-features _generated_diagnostic_collection_name_#2 [[{"$mid":1,"fsPath":"/home/dmeadows/code/phoenix/.vscode/settings.json","external":"file:///home/dmeadows/code/phoenix/.vscode/settings.json","path":"/home/dmeadows/code/phoenix/.vscode/settings.json","scheme":"file"},[{"startLineNumber":6,"startColumn":5,"endLineNumber":6,"endColumn":41,"message":"This setting will soon be deprecated. Please use the Autopep8 extension or the Black Formatter extension. Learn more here: https://aka.ms/AAlgvkb.","code":"2","severity":4,"modelVersionId":414}]]]
2023-08-22 10:48:41.450 [trace] ExtHostCommands#executeCommand setContext
2023-08-22 10:48:41.450 [trace] ExtHostCommands#executeCommand _setContext
2023-08-22 10:48:41.480 [trace] [DiagnosticCollection] change many (extension, owner, uris) ms-python.python python [[{"$mid":1,"fsPath":"/ignoredSettings","external":"vscode://schemas/ignoredSettings","path":"/ignoredSettings","scheme":"vscode","authority":"schemas"},[]]]
2023-08-22 10:48:41.481 [trace] [DiagnosticCollection] change many (extension, owner, uris) ms-python.python python [[{"$mid":1,"fsPath":"/ignoredSettings","external":"vscode://schemas/ignoredSettings","path":"/ignoredSettings","scheme":"vscode","authority":"schemas"},[]]]
2023-08-22 10:48:41.530 [trace] ExtHostCommands#executeCommand setContext
2023-08-22 10:48:41.530 [trace] ExtHostCommands#executeCommand _setContext
2023-08-22 10:48:41.571 [trace] [DiagnosticCollection] change many (extension, owner, uris) vscode.json-language-features _generated_diagnostic_collection_name_#2 [[{"$mid":1,"fsPath":"c:/Users/dmeadows/AppData/Roaming/Code/User/settings.json","external":"vscode-userdata:/c%3A/Users/dmeadows/AppData/Roaming/Code/User/settings.json","path":"/C:/Users/dmeadows/AppData/Roaming/Code/User/settings.json","scheme":"vscode-userdata"},[]]]
2023-08-22 10:48:41.621 [trace] ExtHostCommands#executeCommand setContext
2023-08-22 10:48:41.621 [trace] ExtHostCommands#executeCommand _setContext```
@github-actions github-actions bot added the triage-needed Issue is not triaged. label Aug 22, 2023
@jingo64
Copy link
Author

jingo64 commented Aug 22, 2023

Aaaand after all of that, I closed and re-opened VS Code and it works 🙃 . Nevermind!

@jingo64 jingo64 closed this as completed Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage-needed Issue is not triaged.
Projects
None yet
Development

No branches or pull requests

1 participant