microsoft / vscode-ripgrep

For consuming the ripgrep binary from microsoft/ripgrep-prebuilt in a Node project
Other
105 stars 47 forks source link

download.js fails to handle invalid downloads #61

Open scrpr opened 2 weeks ago

scrpr commented 2 weeks ago

When ripgrep downloads are corrupted or interrupted by ctrl+c, the next run fails with:

Using cached download: C:\Users\[redacted]\AppData\Local\Temp\vscode-ripgrep-cache-1.15.9\ripgrep-v13.0.0-10-x86_64-pc-windows-msvc.zip
Unzipping to [redacted]\node_modules\.pnpm\@vscode+ripgrep@1.15.9\node_modules\@vscode\ripgrep\bin
[redacted]\node_modules\.pnpm\@vscode+ripgrep@1.15.9\node_modules\@vscode\ripgrep\lib\download.js:198
                    zipFile.close();
                            ^

TypeError: Cannot read properties of undefined (reading 'close')
    at [redacted]\node_modules\.pnpm\@vscode+ripgrep@1.15.9\node_modules\@vscode\ripgrep\lib\download.js:198:29
    at [redacted]\node_modules\.pnpm\yauzl@2.10.0\node_modules\yauzl\index.js:37:7
    at [redacted]\node_modules\.pnpm\yauzl@2.10.0\node_modules\yauzl\index.js:187:5
    at [redacted]\node_modules\.pnpm\yauzl@2.10.0\node_modules\yauzl\index.js:631:5
    at [redacted]\node_modules\.pnpm\fd-slicer@1.1.0\node_modules\fd-slicer\index.js:32:7
    at FSReqCallback.wrapper [as oncomplete] (node:fs:682:5)

Node.js v20.14.0

one possible workaround is to remove zipFile.close() as there is no valid zip file to open.

JinMokai commented 4 days ago

I tried to install the mdn documentation dependencies today, node version is 18.18.2, and the installation gave the same error The package management tool used is yarn But it doesn't affect the operation of my project

scrpr commented 4 days ago

But it doesn't affect the operation of my project

Some projects require rg.exe to be present, if your project didn't use this, it'll be unrelated. Currently the only way to fix this problem is to remove node module caches so that the binary could be re-downloaded again.