grafana/k6 · error

%s should be a time duration value: %w

Error message

%s should be a time duration value: %w

What it means

parseTimeOpt converts the K6_BROWSER_GLOBAL_TIMEOUT environment variable via types.GetDurationValue. That helper accepts Go/k6 duration strings ("30s", "1m30s", "1h", or a bare number of milliseconds); anything unparseable makes Parse fail, and the message includes both the variable name and the underlying parse error from the %w chain.

Source

Thrown at internal/js/modules/k6/browser/common/browser_options.go:146

	}
	_, ignore := shouldIgnoreIfBrowserIsRemote[opt]

	return ignore
}

func parseBoolOpt(k, v string) (bool, error) {
	b, err := strconv.ParseBool(v)
	if err != nil {
		return false, fmt.Errorf("%s should be a boolean", k)
	}

	return b, nil
}

func parseTimeOpt(k, v string) (time.Duration, error) {
	t, err := types.GetDurationValue(v)
	if err != nil {
		return time.Duration(0), fmt.Errorf("%s should be a time duration value: %w", k, err)
	}

	return t, nil
}

func parseListOpt(v string) []string {
	elems := strings.Split(v, ",")
	// If last element is a void string,
	// because value contained an ending comma,
	// remove it
	if elems[len(elems)-1] == "" {
		elems = elems[:len(elems)-1]
	}

	return elems
}

View on GitHub (pinned to 93accf6570)

Solutions

  1. Use a Go duration literal: K6_BROWSER_GLOBAL_TIMEOUT=30s or 1m or 1h30m.
  2. A bare integer is treated as milliseconds (e.g. 30000 for 30s); use that form if convenient.
  3. Verify no stray quotes or units like "ms" appended twice ("30sms").

Example fix

# before
export K6_BROWSER_GLOBAL_TIMEOUT='30 seconds'

# after
export K6_BROWSER_GLOBAL_TIMEOUT=30s
Defensive patterns

Strategy: validation

Validate before calling

# verify duration parses as Go/k6 duration (integer also OK: treated as ms)
V="${K6_BROWSER_GLOBAL_TIMEOUT:-}"
[ -z "$V" ] || echo "$V" | grep -qxE '([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+|[0-9]+' \
  || { echo "K6_BROWSER_GLOBAL_TIMEOUT is not a duration: '$V'" >&2; exit 1; }

Prevention

When it happens

Trigger: Setting K6_BROWSER_GLOBAL_TIMEOUT to a non-duration string such as "thirty seconds", "30 sec" (space form), "1.5 minutes", or "timeout".

Common situations: Configuring a global browser timeout in CI with human-readable text; copying values from documentation of other tools; locale differences like comma decimals ("1,5s").

Related errors


AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15). Data as JSON: /api/errors/8aed59cb4f01b9bb. Report an issue: GitHub.