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

Server crashes with Libzip Error #1397

Closed
johntmyers opened this issue Jun 4, 2021 · 10 comments
Closed

Server crashes with Libzip Error #1397

johntmyers opened this issue Jun 4, 2021 · 10 comments
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@johntmyers
Copy link

Environment data

  • Language Server version: Pylance language server 2021.6.1-pre.1 (pyright 209c8040) starting
  • OS and version: Mac OS 11.2.3
  • Python version (& distribution if applicable, e.g. Anaconda): 3.7.9

Expected behaviour

The server should run

Actual behaviour

The server crashes, and does not properly restart

Logs

[Warn  - 11:50:33 AM] Workspace indexing has hit its upper limit: 2000 files
Background analysis message: getDiagnosticsForRange
Background analysis message: getDiagnosticsForRange
Background analysis message: getDiagnosticsForRange
Background analysis message: getDiagnosticsForRange
Background analysis message: getDiagnosticsForRange
Received updated settings
Libzip Error: Not a zip archive
    at makeLibzipError (/Users/jtm/.vscode/extensions/ms-python.vscode-pylance-2021.6.1-pre.1/dist/pyright-internal/node_modules/@yarnpkg/fslib/lib/ZipFS.js:149:29)
    at new m (/Users/jtm/.vscode/extensions/ms-python.vscode-pylance-2021.6.1-pre.1/dist/pyright-internal/node_modules/@yarnpkg/fslib/lib/ZipFS.js:121:28)
    at getZipSync (/Users/jtm/.vscode/extensions/ms-python.vscode-pylance-2021.6.1-pre.1/dist/pyright-internal/node_modules/@yarnpkg/fslib/lib/ZipOpenFS.js:784:28)
    at g.makeCallSync (/Users/jtm/.vscode/extensions/ms-python.vscode-pylance-2021.6.1-pre.1/dist/pyright-internal/node_modules/@yarnpkg/fslib/lib/ZipOpenFS.js:665:21)
    at g.existsSync (/Users/jtm/.vscode/extensions/ms-python.vscode-pylance-2021.6.1-pre.1/dist/pyright-internal/node_modules/@yarnpkg/fslib/lib/ZipOpenFS.js:232:21)
    at c.existsSync (/Users/jtm/.vscode/extensions/ms-python.vscode-pylance-2021.6.1-pre.1/dist/pyright-internal/node_modules/@yarnpkg/fslib/lib/ProxiedFS.js:71:28)
    at r.existsSync (/Users/jtm/.vscode/extensions/ms-python.vscode-pylance-2021.6.1-pre.1/dist/pyright-internal/node_modules/@yarnpkg/fslib/lib/ProxiedFS.js:71:28)
    at T.existsSync (/Users/jtm/.vscode/extensions/ms-python.vscode-pylance-2021.6.1-pre.1/dist/pyright-internal/src/common/fileSystem.ts:213:23)
    at t.PyrightFileSystem.existsSync (/Users/jtm/.vscode/extensions/ms-python.vscode-pylance-2021.6.1-pre.1/dist/pyright-internal/src/pyrightFileSystem.ts:63:29)
    at /Users/jtm/.vscode/extensions/ms-python.vscode-pylance-2021.6.1-pre.1/dist/pyright-internal/src/analyzer/service.ts:1027:53
[Info  - 12:01:02 PM] Connection to server got closed. Server will restart.
[Error - 12:01:02 PM] Request textDocument/hover failed.
Error: Connection got disposed.
	at Object.dispose (/Users/jtm/.vscode/extensions/ms-python.python-2021.5.842923320/out/client/extension.js:59:68124)
	at Object.dispose (/Users/jtm/.vscode/extensions/ms-python.python-2021.5.842923320/out/client/extension.js:9:178020)
	at E.handleConnectionClosed (/Users/jtm/.vscode/extensions/ms-python.python-2021.5.842923320/out/client/extension.js:9:178232)
	at E.handleConnectionClosed (/Users/jtm/.vscode/extensions/ms-python.python-2021.5.842923320/out/client/extension.js:59:21817)
	at t (/Users/jtm/.vscode/extensions/ms-python.python-2021.5.842923320/out/client/extension.js:9:176325)
	at invoke (/Users/jtm/.vscode/extensions/ms-python.python-2021.5.842923320/out/client/extension.js:9:318740)
	at o.fire (/Users/jtm/.vscode/extensions/ms-python.python-2021.5.842923320/out/client/extension.js:9:319501)
	at X (/Users/jtm/.vscode/extensions/ms-python.python-2021.5.842923320/out/client/extension.js:59:57486)
	at invoke (/Users/jtm/.vscode/extensions/ms-python.python-2021.5.842923320/out/client/extension.js:9:318740)
	at o.fire (/Users/jtm/.vscode/extensions/ms-python.python-2021.5.842923320/out/client/extension.js:9:319501)
	at d.fireClose (/Users/jtm/.vscode/extensions/ms-python.python-2021.5.842923320/out/client/extension.js:59:47555)
	at ChildProcess.<anonymous> (/Users/jtm/.vscode/extensions/ms-python.python-2021.5.842923320/out/client/extension.js:9:314470)
	at ChildProcess.emit (events.js:327:22)
	at maybeClose (internal/child_process.js:1048:16)
	at Socket.<anonymous> (internal/child_process.js:439:11)
	at Socket.emit (events.js:315:20)
	at Pipe.<anonymous> (net.js:673:12)
[Info  - 12:01:02 PM] Pylance language server 2021.6.1-pre.1 (pyright 209c8040) starting
[Info  - 12:01:02 PM] Server root directory: /Users/jtm/.vscode/extensions/ms-python.vscode-pylance-2021.6.1-pre.1/dist
@github-actions github-actions bot added the triage label Jun 4, 2021
@jakebailey
Copy link
Member

Interesting. Do you have any zip or egg files in your workspace, by chance?

@johntmyers
Copy link
Author

Yeah, always have because of some of the other tools we use that create various artifacts. This just started happening today though which is weird.

@jakebailey
Copy link
Member

jakebailey commented Jun 4, 2021

The latest version of Pylance released on Wednesday adds support for zip/egg files, which the Python interpreter transparently opens when loading modules. That's probably why you're seeing this, and the initial workspace scan goes and explores them. It's likely that one of these files is malformed and we fail to access it.

Perhaps it shouldn't try and do this inside of the workspace (only allowing eggs within site-packages), or at least limit to .egg only to avoid random zip accesses.

(The exists call also should not be throwing, which I can try and work around.)

@johntmyers
Copy link
Author

Ok, I'm not sure what new files would have gotten into my workspace in the last couple of days for this to stop working today. Also seems odd that the server doesn't actually start back up (contrary to the second to last log line)

@erictraut
Copy link
Contributor

I think it's fine for the scan to open zips, but we need to have the appropriate exception handling in place so errors don't crash the language server. If a zip is malformed, we should just catch the exception and ignore the error.

@jakebailey
Copy link
Member

Yeah, existsSync should never throw, it should just return false (based on my understanding of node's FS module). Clearly the FS abstraction I added to support zips/eggs didn't keep that assumption, so I will fix that.

@ducalpha
Copy link

ducalpha commented Jun 7, 2021

I am getting the same problem and I have to downgraded Pylance to 2021.5.4. Is there any workaround available?

Environment data

Language Server version: Pylance language server 2021.6.0
OS and version: Ubuntu 18.04
Python version (& distribution if applicable, e.g. Anaconda): 3.8.10

Error messages:

[Info  - 8:41:53 ] Pylance language server 2021.6.0 (pyright 209c8040) starting
[Info  - 8:41:53 ] Server root directory: /home//.vscode-server/extensions/ms-python.vscode-pylance-2021.6.0/dist
[Error - 8:41:54] Exception received when installing recursive file system watcher: TypeError [ERR_FEATURE_UNAVAILABLE_ON_PLATFORM]: The feature watch recursively is unavailable on the current platform, which is being used to run Node.js
Libzip Error: Not a zip archive
    at makeLibzipError (/home//.vscode-server/extensions/ms-python.vscode-pylance-2021.6.0/dist/pyright-internal/node_modules/@yarnpkg/fslib/lib/ZipFS.js:149:29)
    at new m (/home//.vscode-server/extensions/ms-python.vscode-pylance-2021.6.0/dist/pyright-internal/node_modules/@yarnpkg/fslib/lib/ZipFS.js:121:28)
    at getZipSync (/home//.vscode-server/extensions/ms-python.vscode-pylance-2021.6.0/dist/pyright-internal/node_modules/@yarnpkg/fslib/lib/ZipOpenFS.js:784:28)
    at g.makeCallSync (/home//.vscode-server/extensions/ms-python.vscode-pylance-2021.6.0/dist/pyright-internal/node_modules/@yarnpkg/fslib/lib/ZipOpenFS.js:665:21)
    at g.existsSync (/home//.vscode-server/extensions/ms-python.vscode-pylance-2021.6.0/dist/pyright-internal/node_modules/@yarnpkg/fslib/lib/ZipOpenFS.js:232:21)
    at c.existsSync (/home//.vscode-server/extensions/ms-python.vscode-pylance-2021.6.0/dist/pyright-internal/node_modules/@yarnpkg/fslib/lib/ProxiedFS.js:71:28)
    at r.existsSync (/home//.vscode-server/extensions/ms-python.vscode-pylance-2021.6.0/dist/pyright-internal/node_modules/@yarnpkg/fslib/lib/ProxiedFS.js:71:28)
    at T.existsSync (/home//.vscode-server/extensions/ms-python.vscode-pylance-2021.6.0/dist/pyright-internal/src/common/fileSystem.ts:213:23)
    at t.PyrightFileSystem.existsSync (/home//.vscode-server/extensions/ms-python.vscode-pylance-2021.6.0/dist/pyright-internal/src/pyrightFileSystem.ts:63:29)
    at /home//.vscode-server/extensions/ms-python.vscode-pylance-2021.6.0/dist/pyright-internal/src/analyzer/service.ts:1027:53
[Info  - 8:44:34 PM] Connection to server got closed. Server will restart.

@judej judej added bug Something isn't working in backlog labels Jun 7, 2021
@github-actions github-actions bot removed the triage label Jun 7, 2021
@jakebailey
Copy link
Member

The next release includes a fix for this.

@jakebailey jakebailey added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label Jun 8, 2021
@BrandonLWhite
Copy link

Found this issue while searching for a solution to my Libzip Error: Not a zip archive error. In my particular project we have test cases for handling of corrupt zip files as well as files that have the extension .zip but are actually some other compression format. I narrowed it down to Pylance crashing on these test input files that it found in our ./tests/data/in/ directory.

Thanks for the quick fix, and I look forward to the next release.

@jakebailey
Copy link
Member

This issue has been fixed in version 2021.6.1, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202161-9-june-2021

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

6 participants