grafana/k6 · error
setting downloads path
Error message
setting downloads path: %w
What it means
NewBrowserContext wraps setDownloadsPath, which assigns an explicit path directly (no error) or creates a temp directory when no downloadsPath is configured. This error therefore surfaces the temp-directory creation failure (see [615]) one level up, at the point the context is being constructed.
Solutions
- Set TMPDIR to a writable directory with free space
- Free disk space and inodes on the runner
- Raise open-file limits (ulimit -n / container pids/fd limits)
- Configure an explicit downloads path in the browser options so no temp dir is created
Example fix
# before k6 run script.js # runner has read-only /tmp -> setting downloads path: ... # after TMPDIR=/var/tmp/k6 k6 run script.js # /var/tmp/k6 exists and is writable
Defensive patterns
Strategy: validation
Validate before calling
# Ensure a usable downloads/temp location pre-run
test -w "${TMPDIR:-/tmp}" || export TMPDIR=/var/tmp/k6 && mkdir -p "$TMPDIR"
k6 run script.js Prevention
- Set TMPDIR to a known-writable path in CI
- Configure an explicit downloads path in browser options
- Check disk space and fd limits before browser-heavy runs
When it happens
Trigger: Creating any browser context (including the default one at connect) with no explicit downloads path while the OS temp dir is unwritable, full, or fd-exhausted on the k6 runner.
Common situations: Read-only /tmp in CI containers; disk-full agents; TMPDIR pointing at a missing path; high concurrency exhausting file descriptors.
Related errors
- creating temporary directory for downloads
- removing downloads path
- access token not configured
- adding init script to browser context
- adding web vital init script to new browser context
AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18).
Data as JSON: /api/errors/5dc963d700cdbb41.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/common/browser_context.go:157
logger: logger,
timeoutSettings: NewTimeoutSettings(nil),
}
if len(opts.Permissions) > 0 {
err := b.GrantPermissions(opts.Permissions, GrantPermissionsOptions{})
if err != nil {
return nil, err
}
}
if err := b.AddInitScript(js.WebVitalIIFEScript); err != nil {
return nil, fmt.Errorf("adding web vital script to new browser context: %w", err)
}
if err := b.AddInitScript(js.WebVitalInitScript); err != nil {
return nil, fmt.Errorf("adding web vital init script to new browser context: %w", err)
}
if err := b.setDownloadsPath(opts.DownloadsPath); err != nil {
return nil, fmt.Errorf("setting downloads path: %w", err)
}
return &b, nil
}
// AddInitScript adds a script that will be initialized on all new pages.
func (b *BrowserContext) AddInitScript(script string) error {
b.logger.Debugf("BrowserContext:AddInitScript", "bctxid:%v", b.id)
b.evaluateOnNewDocumentSources = append(b.evaluateOnNewDocumentSources, script)
for _, p := range b.browser.getPages() {
if err := p.evaluateOnNewDocument(script); err != nil {
return fmt.Errorf("adding init script to browser context: %w", err)
}
}
return nilView on GitHub (pinned to 01ffac6f24)