Fix CLI download startup crash on VS Code >=1.123 by nygrenh · Pull Request #780 · rage/tmc-vscode · GitHub
Skip to content

Fix CLI download startup crash on VS Code >=1.123#780

Merged
nygrenh merged 2 commits into
masterfrom
fix
Jun 12, 2026
Merged

Fix CLI download startup crash on VS Code >=1.123#780
nygrenh merged 2 commits into
masterfrom
fix

Conversation

@nygrenh

@nygrenh nygrenh commented Jun 12, 2026

Copy link
Copy Markdown
Member
  • Fix CLI download startup crash on VS Code >=1.123
  • Harden CLI verification and download error handling

nygrenh added 2 commits June 12, 2026 20:46
downloadFile() never flushed or closed its write stream (the awaits on write()/close() awaited non-promises), so the small .sha256 file could be read back empty, producing a checksum "mismatch". The recovery path then deleted the cli folder while that file's handle was still open and returned Ok without re-verifying. On Node 24 (VS Code 1.123+) that unflushed-handle delete throws ENOTEMPTY, killing activation.

- utils.ts: stream the download with real backpressure (await drain) and await stream/promises finished() so the data is flushed and the fd closed before returning; destroy the stream on error so no handle leaks.
- ensureLangsUpdated.ts: extract verifyCli(); re-verify the checksum after a redownload (Err on persistent mismatch instead of trusting it); replace del's deleteSync with removeCliFolder() using fs.rm {maxRetries, retryDelay}, returning a Result so a failed delete can't crash activation; harden parseSha256Sum; add an optional opts {downloadUrl, version} for testing.
- Tests: new downloadFile suite (incl. the empty-read regression) and end-to-end ensureLangsUpdated coverage, including the real uppercase+CRLF 0.39.4 checksum format.
- Bump to 3.5.3 + CHANGELOG.
@nygrenh nygrenh merged commit 18352f2 into master Jun 12, 2026
5 checks passed
@nygrenh nygrenh deleted the fix branch June 12, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant