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

Diagnostics from open files sometime not cleared up when file is closed. #5402

Open
heejaechang opened this issue Jan 25, 2024 · 6 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@heejaechang
Copy link
Contributor

  1. open single folder in vscode
  2. and do FAR on Path - https://github.com/microsoft/pylance-release/blob/main/testing/single/src/findallreferences.py#L6
  3. and click all files references are found

Expected: diagnostics are cleared as new file is opened and old files are automatically closed.
Actual: diagnostics are left in problems tab for long time (but it eventually goes away)

...

this repro with 2023.12.1 so must be existing bug.

it eventually goes away so it could be a perf issue. (such as even if a file is closed, we don't cancel pending request such as semantic token or checker requests running in BG so BG is staled or something like that)

@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Jan 25, 2024
@rchiodo
Copy link
Contributor

rchiodo commented Apr 18, 2024

I think this might be a VS code issue.

We get this during find all references for a file that isn't open:

2024-04-18 16:26:11.415 [info] [Trace - 4:26:11 PM] Sending notification 'textDocument/didOpen'.
2024-04-18 16:26:11.415 [info] Params: {"textDocument":{"uri":"file:///c%3A/Users/rchiodo/source/repos/pylance-release/testing/single/src/lib/__init__.py","languageId":"python","version":1,"text":"# this file conatins references used by other test files.\r\n\r\nfrom findallreferences import FindConstructor\r\n\r\n# object instantiation reference\r\nFindConstructor()\r\n\r\nxx"}}

Which then causes us to show diagnostics for a file that isn't open.

@rchiodo
Copy link
Contributor

rchiodo commented Apr 18, 2024

I can reproduce this with typescript code too. It's not just python.

@rchiodo
Copy link
Contributor

rchiodo commented Apr 18, 2024

See this:
microsoft/vscode#205790

It seems we need to switch to a pull model if we want this to work correctly. It has to do with hidden tabs.

@rchiodo
Copy link
Contributor

rchiodo commented Apr 18, 2024

In fact the documentation for pull mentions that textDocument/didOpen didClose are not a consistent method to actually tell what files are visible in the editor:

https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_pullDiagnostics

@rchiodo
Copy link
Contributor

rchiodo commented Apr 18, 2024

Did open specifically says this:

DidOpenTextDocument Notification (:arrow_right:)
The document open notification is sent from the client to the server to signal newly opened text documents. The document’s content is now managed by the client and the server must not try to read the document’s content using the document’s Uri. Open in this sense means it is managed by the client. It doesn’t necessarily mean that its content is presented in an editor.

@rchiodo rchiodo added bug Something isn't working and removed needs repro Issue has not been reproduced yet labels Apr 19, 2024
@rchiodo
Copy link
Contributor

rchiodo commented Apr 19, 2024

Switching to a pull method can sort of work, but I believe there's a bug in vscode-language-client:
microsoft/vscode-languageserver-node#1464

@rchiodo rchiodo added the waiting for upstream Waiting for upstream to release a fix label May 2, 2024
rchiodo added a commit to microsoft/vscode-python that referenced this issue Jun 17, 2024
This is a prerequisite to fixing this pylance issue:
microsoft/pylance-release#5402

---------

Co-authored-by: Erik De Bonte <erikd@microsoft.com>
@rchiodo rchiodo removed the waiting for upstream Waiting for upstream to release a fix label Jun 19, 2024
DonJayamanne pushed a commit to DonJayamanne/pythonVSCode that referenced this issue Jun 24, 2024
This is a prerequisite to fixing this pylance issue:
microsoft/pylance-release#5402

---------

Co-authored-by: Erik De Bonte <erikd@microsoft.com>
eleanorjboyd pushed a commit to eleanorjboyd/vscode-python that referenced this issue Jun 28, 2024
This is a prerequisite to fixing this pylance issue:
microsoft/pylance-release#5402

---------

Co-authored-by: Erik De Bonte <erikd@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants