grafana/k6 · error

k6/experimental/timers has been graduated, and it's now…

Error message

k6/experimental/timers has been graduated, and it's now globally available as defined by standard WebAPIs. You just need to remove the import.

What it means

k6/experimental/timers graduated: setTimeout/setInterval (and the *Async k6 APIs' timer semantics) are now global standard WebAPIs in the runtime. Importing the old module path throws via the removedModule stub (internal/js/jsmodules.go:107); the fix is to delete the import, not to rename it.

Solutions

  1. Delete the `k6/experimental/timers` import line entirely.
  2. Call setTimeout/setInterval directly — they are globally available.
  3. If a bundler injected the import, exclude k6 modules from bundling.

Example fix

// before
import { setTimeout } from 'k6/experimental/timers';
setTimeout(() => {}, 100);
// after
setTimeout(() => {}, 100);
Defensive patterns

Strategy: validation

Validate before calling

# codemod check: timers must not be imported at all
if grep -rn "k6/experimental/timers" . --include='*.js'; then
  echo 'setTimeout/setInterval are global - delete the import'; exit 1
fi

Prevention

When it happens

Trigger: `import { setTimeout } from 'k6/experimental/timers'` (or setInterval/sleep from it) on modern k6 — instantiation of the removed module throws.

Common situations: Scripts that polyfilled timers before graduation; bundlers that preserve the now-dead import; copy-paste from early async-k6 examples.

Related errors


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

Appendix: source

Thrown at internal/js/jsmodules.go:107

	// external is always prefixed with `k6/x`
	for _, e := range external {
		result[e.Name] = e.Module
	}

	return result
}

type removedModule struct {
	errMsg string
}

func newRemovedModule(errMsg string) modules.Module {
	return &removedModule{errMsg: errMsg}
}

func (rm *removedModule) NewModuleInstance(vu modules.VU) modules.Instance {
	common.Throw(vu.Runtime(), errors.New(rm.errMsg))

	return nil
}

type warnExperimentalModule struct {
	once sync.Once
	msg  string
	base modules.Module
}

func newWarnExperimentalModule(base modules.Module, msg string) modules.Module {
	return &warnExperimentalModule{
		msg:  msg,
		base: base,
	}
}

func (w *warnExperimentalModule) NewModuleInstance(vu modules.VU) modules.Instance {

View on GitHub (pinned to 01ffac6f24)