Skip to content

fix: preserve user downloadsPath and reject non-positive http.batch - #6261

Draft
cursor[bot] wants to merge 1 commit into
masterfrom
cursor/critical-bug-investigation-334b
Draft

fix: preserve user downloadsPath and reject non-positive http.batch#6261
cursor[bot] wants to merge 1 commit into
masterfrom
cursor/critical-bug-investigation-334b

Conversation

@cursor

@cursor cursor Bot commented Aug 8, 2026

Copy link
Copy Markdown

What?

Two high-severity correctness fixes:

  1. Browser downloadsPath data loss: BrowserContext.cleanup() always called os.RemoveAll on DownloadsPath, including user-supplied paths. On browser.close(), a path like /tmp or a project downloads directory was recursively deleted. Only temporary directories created by k6 are removed now (same ownership pattern as storage.Dir).

  2. http.batch hang: With options.batch <= 0 (or K6_BATCH=0), MakeBatchRequests spawned zero workers and http.batch() blocked forever waiting for results. Non-positive batch / batchPerHost are rejected in Options.Validate(), and MakeBatchRequests fails closed instead of hanging.

Why?

  • Data loss: user-facing downloadsPath is a supported BrowserContext option; unit tests even use /tmp as an example value. Closing the browser must not wipe that tree.
  • Hang: batch: 0 is accepted by config today and turns any http.batch([...]) into a permanent VU deadlock until scenario timeout.

Checklist

  • I have performed a self-review of my code.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests for my changes.
  • I have run linter and tests locally (make check) and all pass.

Targeted validation run:

  • go test -race ./internal/js/modules/k6/browser/common/ -run TestSetDownloadsPath
  • go test -race ./lib/ -run TestOptions
  • go test -race ./lib/netext/httpext/ -run TestMakeBatchRequests

Checklist: Documentation (only for k6 maintainers and if relevant)

  • I have added the correct milestone and labels to the PR.
  • I have updated the release notes: link
  • I have updated or added an issue to the k6-documentation: grafana/k6-docs#NUMBER if applicable
  • I have updated or added an issue to the TypeScript definitions: grafana/k6-DefinitelyTyped#NUMBER if applicable

Related PR(s)/Issue(s)

Found by critical-bug investigation automation on tip 53b5727d8.

Open in Web View Automation 

BrowserContext.cleanup() always called os.RemoveAll on DownloadsPath,
including user-supplied directories such as /tmp or a project downloads
folder, causing recursive data loss on browser.close(). Only remove
temporary directories that k6 created.

http.batch() with options.batch <= 0 spawned zero workers and blocked
forever waiting for results. Reject non-positive batch/batchPerHost in
Options.Validate and fail closed in MakeBatchRequests.

Co-authored-by: Inanc Gumus <github@inanc.io>
@cla-assistant

cla-assistant Bot commented Aug 8, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@cursor
cursor Bot temporarily deployed to azure-trusted-signing August 8, 2026 11:21 Inactive
@cursor
cursor Bot deployed to azure-trusted-signing August 8, 2026 11:22 Active
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