Skip to content

Refactor unzip functionality to limit concurrency and improve error handling in copyStream#4455

Merged
josefs merged 3 commits into
mainfrom
shati-patel/fix-cli-extraction
Jul 16, 2026
Merged

Refactor unzip functionality to limit concurrency and improve error handling in copyStream#4455
josefs merged 3 commits into
mainfrom
shati-patel/fix-cli-extraction

Conversation

@shati-patel

Copy link
Copy Markdown
Contributor

Fixes #4453

Discussed with @josefs and tried various other fixes locally (like limiting the number of available cores). Eventually settled on this change to copyStream.

I installed the dev VSIX build locally and can confirm that the extraction now works smoothly 🎉


Note: this still needs a changelog note and potentially some tidy-up

@josefs

josefs commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Great start @shati-patel . I've pushed a commit to also add timeouts, in case something goes wrong with the writing. That will give us an extra layer or protection.

@josefs josefs force-pushed the shati-patel/fix-cli-extraction branch from ac3da10 to d23ed63 Compare July 16, 2026 10:44
@josefs josefs force-pushed the shati-patel/fix-cli-extraction branch from d23ed63 to c593313 Compare July 16, 2026 11:26
@josefs

josefs commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

I've added a test for the timeout and reworked the other test a bit. This is ready for review now.

@josefs josefs marked this pull request as ready for review July 16, 2026 11:27
@josefs josefs requested a review from a team as a code owner July 16, 2026 11:27
Copilot AI review requested due to automatic review settings July 16, 2026 11:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses reported stalls during CodeQL CLI installation/update by making archive extraction more resilient: extraction concurrency is capped, stream copy failures propagate correctly, and extraction will abort with a clear error if progress stops for too long (using the configured download timeout when extracting the CLI distribution).

Changes:

  • Refactor copyStream to use stream/promises.pipeline (better error propagation + optional abort signal support).
  • Add an idle-timeout abort mechanism to unzip operations, and thread the timeout through sequential and concurrent unzip entry points.
  • Limit unzip concurrency (cap at 4) to reduce simultaneous writes during extraction, and add unit tests covering the new error/timeout handling.
Show a summary per file
File Description
extensions/ql-vscode/test/unit-tests/common/unzip.test.ts Adds unit tests validating copyStream rejection on write errors and abort-on-idle behavior.
extensions/ql-vscode/src/common/unzip.ts Refactors stream copy to pipeline, adds idle-timeout abort for unzip, and plumbs timeout/signal through extraction.
extensions/ql-vscode/src/common/unzip-concurrently.ts Caps concurrent extraction tasks to avoid overwhelming storage; forwards timeout to unzip core.
extensions/ql-vscode/src/codeql-cli/distribution.ts Passes the configured download timeout into extraction so stalled extraction aborts predictably.
extensions/ql-vscode/CHANGELOG.md Documents the user-facing fix for hangs during CLI extraction and the new timeout behavior.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Low

Comment on lines +256 to +260
} catch (e) {
if (signal.aborted) {
throw new Error(
`Timed out while extracting archive: no progress was made for ${timeoutSeconds} seconds. ` +
"This can happen if a file cannot be written, for example because of slow or networked storage, " +
@josefs josefs requested review from kaspersv and nickrolfe July 16, 2026 12:01
Comment thread extensions/ql-vscode/src/common/unzip.ts
Comment thread extensions/ql-vscode/src/common/unzip-concurrently.ts
@josefs josefs merged commit 52672e6 into main Jul 16, 2026
96 of 111 checks passed
@josefs josefs deleted the shati-patel/fix-cli-extraction branch July 16, 2026 14:00
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.

Updating CodeQL CLI stalls EVERY TIME visual studio code is opened

4 participants