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

"Received redundant open text document command" when working off mapped network drive #5326

Closed
slingshotvfx opened this issue Jan 4, 2024 · 6 comments
Assignees
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@slingshotvfx
Copy link

slingshotvfx commented Jan 4, 2024

Environment data

  • Language Server version: v2023.12.1
  • OS and version: Windows 11
  • Python version (& distribution if applicable, e.g. Anaconda): 3.12

Repro Steps

In windows, let's say I have \\server\storage mapped to z:\

Fairly regularly when working on a file Pylance will crash with this error:

2023-12-21 19:58:52.027 [info] [Error - 7:58:52 PM] (51164) Received redundant open text document command for \\server\storage\test\test.py

And then pylance no longer functions on that file until you close and reopen it within VS Code.

An easy way to trigger this is to hit f2 or click "Rename symbol", so this might be related to #5030. However, I get frequent crashes when working on a python file even without renaming a symbol specifically.

Logs

Renaming a symbol in z:\test\test.py results in the following error:

2024-01-03 20:25:50.240 [info] [Error - 8:25:50 PM] (22072) Received redundant open text document command for \\server\storage\test\test.py
2024-01-03 20:25:50.509 [info] (22072) [BG(1)] analyzing: \\server\storage\test\test.py ...
2024-01-03 20:25:50.509 [info] (22072) [BG(1)]   parsing: \\server\storage\test\test.py (8ms)
2024-01-03 20:25:50.509 [info] (22072) [BG(1)]   binding: \\server\storage\test\test.py (0ms)
2024-01-03 20:25:50.512 [info] (22072) [BG(1)]   checking: \\server\storage\test\test.py (3ms)
2024-01-03 20:25:50.512 [info] (22072) [BG(1)] analyzing: \\server\storage\test\test.py (11ms)
2024-01-03 20:25:50.512 [info] (22072) [BG(1)] indexing: \\server\storage\test\test.py [found 1] (0ms)

If you keep typing after that:

2024-01-03 20:41:58.581 [info] [Error - 8:41:58 PM] (33908) Received change text document command for closed file \\server\storage\test\test.py
2024-01-03 20:41:58.629 [info] [Error - 8:41:58 PM] (33908) Received change text document command for closed file \\server\storage\test\test.py
2024-01-03 20:41:58.649 [info] [Error - 8:41:58 PM] (33908) Received change text document command for closed file \\server\storage\test\test.py
2024-01-03 20:41:59.016 [info] (33908) [BG(1)] getSemanticTokens full at \\server\storage\test\test.py (0ms)
2024-01-03 20:41:59.849 [info] (33908) [BG(1)] getInlayHints range 0:0 - 4:21 at \\server\storage\test\test.py (0ms)
@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Jan 4, 2024
@rchiodo
Copy link
Contributor

rchiodo commented Jan 4, 2024

I get something different. Attempting to do a rename has this effect:

  ERR Error: Unable to read file '\\tsclient\D\Source\Testing\Testing_Pyright\temp_project\manage.py' (Unknown (FileSystemError): UNC host 'tsclient' access is not allowed. Please update the 'security.allowedUNCHosts' setting if you want to allow this host.)
    at n.F (fileService.ts:631:10)
    at n.D (fileService.ts:616:15)
    at async b.M (textFileService.ts:219:19)
    at async b.readStream (textFileService.ts:198:35)
    at async P.Cb (textFileEditorModel.ts:444:20)
    at async P.resolve (textFileEditorModel.ts:300:3)
    at async s.W (textFileEditorModelManager.ts:416:4)
    at async f.r (textModelResolverService.ts:70:18)
    at async y.acquire (lifecycle.ts:683:19)
    at async d.createModelReference (textModelResolverService.ts:238:10)
    at async Promise.all (index 0)
    at async o.r (bulkTextEdits.ts:275:3)
    at async o.apply (bulkTextEdits.ts:292:17)

My guess is that we're turning the URI for the rename into the real path instead of using the original URI.

@rchiodo rchiodo added the bug Something isn't working label Jan 4, 2024
@slingshotvfx
Copy link
Author

(FileSystemError): UNC host 'tsclient' access is not allowed. Please update the 'security.allowedUNCHosts' setting if you want to allow this host.)

You may need to add "tsclient" to the Security: Allowed UNCHosts setting in VS Code. Or disable Security: Restrict UNCAccess

Also, rolling back to pylance v2023.10.50 does solve this issue for me.

@rchiodo
Copy link
Contributor

rchiodo commented Jan 4, 2024

That does get me farther, the rename occurs but we open a new file (instead of just renaming inside the current file). Well because the URI we return for the rename has the real path instead of the mapped one.

@rchiodo
Copy link
Contributor

rchiodo commented Jan 4, 2024

I start getting these then:

2024-01-04 11:39:43.061 [info] [Error - 11:39:43 AM] (22608) Received change text document command for closed file \\tsclient\D\Source\Testing\Testing_Pyright\temp_project\manage.py

At no point does it stop working though. It's just returning the wrong URIs. Hover still works on the original file, goto def still works. etc.

@rchiodo rchiodo removed the needs repro Issue has not been reproduced yet label Jan 4, 2024
@slingshotvfx
Copy link
Author

I can sometimes reproduce the 'opening a new file' behavior you're seeing. If you close that new file and go back to the original one that is still open, I lose variable coloring and type hints and pylance doesn't work. "Go to definition" opens up a new file again.

in v2023.10.50 the logs show indexing: z:\test\test.py [found 2] (0ms)
in v2023.12.1 the logs show indexing: \\server\storage\test\test.py [found 2] (0ms)

So definitely something related to not knowing the real path and mapped path are the same files.

@PylanceBot PylanceBot added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label Jan 11, 2024
@rchiodo
Copy link
Contributor

rchiodo commented Jan 22, 2024

This issue has been fixed in prerelease version 2023.12.104, which we've just released. You can find the changelog here: CHANGELOG.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

3 participants