grafana/k6 · error

the timeUnit must be more than 0

Error message

the timeUnit must be more than 0

What it means

Raised by RampingArrivalRateConfig.Validate when the scenario's timeUnit option resolves to zero or a negative duration. timeUnit defines the window over which startRate and stage targets are counted, so it must be a positive duration string.

Source

Thrown at lib/executor/ramping_arrival_rate.go:95

	maxArrRatePerSec, _ := getArrivalRatePerSec(
		getScaledArrivalRate(et.Segment, maxUnscaledRate, varc.TimeUnit.TimeDuration()),
	).Float64()

	return fmt.Sprintf("Up to %.2f iterations/s for %s over %d stages%s",
		maxArrRatePerSec, sumStagesDuration(varc.Stages),
		len(varc.Stages), varc.getBaseInfo(maxVUsRange))
}

// Validate makes sure all options are configured and valid
func (varc *RampingArrivalRateConfig) Validate() []error {
	errors := varc.BaseConfig.Validate()

	if varc.StartRate.Int64 < 0 {
		errors = append(errors, fmt.Errorf("the startRate value can't be negative"))
	}

	if varc.TimeUnit.TimeDuration() <= 0 {
		errors = append(errors, fmt.Errorf("the timeUnit must be more than 0"))
	}

	errors = append(errors, validateStages(varc.Stages)...)

	if !varc.PreAllocatedVUs.Valid {
		errors = append(errors, fmt.Errorf("the number of preAllocatedVUs isn't specified"))
	} else if varc.PreAllocatedVUs.Int64 < 0 {
		errors = append(errors, fmt.Errorf("the number of preAllocatedVUs can't be negative"))
	}

	if !varc.MaxVUs.Valid {
		// TODO: don't change the config while validating
		varc.MaxVUs.Int64 = varc.PreAllocatedVUs.Int64
	} else if varc.MaxVUs.Int64 < varc.PreAllocatedVUs.Int64 {
		errors = append(errors, fmt.Errorf("maxVUs can't be less than preAllocatedVUs"))
	}

	return errors

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Set timeUnit to a positive duration such as "1s" or "1ms"
  2. Omit timeUnit to use the default of 1s
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at lib/executor/ramping_arrival_rate.go:95 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18). Data as JSON: /api/errors/412e3c622f2ca077. Report an issue: GitHub.