{"record":{"id":"0cf7294a5e4929c1","repo":"grafana/k6","slug":"k6-experimental-timers-has-been-graduated-and-it","errorCode":null,"errorMessage":"k6/experimental/timers has been graduated, and it's now globally available as defined by standard WebAPIs. You just need to remove the import.","messagePattern":"k6/experimental/timers has been graduated, and it's now globally available as defined by standard WebAPIs\\. You just need to remove the import\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/jsmodules.go","lineNumber":107,"sourceCode":"\n\t// external is always prefixed with `k6/x`\n\tfor _, e := range external {\n\t\tresult[e.Name] = e.Module\n\t}\n\n\treturn result\n}\n\ntype removedModule struct {\n\terrMsg string\n}\n\nfunc newRemovedModule(errMsg string) modules.Module {\n\treturn &removedModule{errMsg: errMsg}\n}\n\nfunc (rm *removedModule) NewModuleInstance(vu modules.VU) modules.Instance {\n\tcommon.Throw(vu.Runtime(), errors.New(rm.errMsg))\n\n\treturn nil\n}\n\ntype warnExperimentalModule struct {\n\tonce sync.Once\n\tmsg  string\n\tbase modules.Module\n}\n\nfunc newWarnExperimentalModule(base modules.Module, msg string) modules.Module {\n\treturn &warnExperimentalModule{\n\t\tmsg:  msg,\n\t\tbase: base,\n\t}\n}\n\nfunc (w *warnExperimentalModule) NewModuleInstance(vu modules.VU) modules.Instance {","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/jsmodules.go#L89-L125","documentation":"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.","triggerScenarios":"`import { setTimeout } from 'k6/experimental/timers'` (or setInterval/sleep from it) on modern k6 — instantiation of the removed module throws.","commonSituations":"Scripts that polyfilled timers before graduation; bundlers that preserve the now-dead import; copy-paste from early async-k6 examples.","solutions":["Delete the `k6/experimental/timers` import line entirely.","Call setTimeout/setInterval directly — they are globally available.","If a bundler injected the import, exclude k6 modules from bundling."],"exampleFix":"// before\nimport { setTimeout } from 'k6/experimental/timers';\nsetTimeout(() => {}, 100);\n// after\nsetTimeout(() => {}, 100);","handlingStrategy":"validation","validationCode":"# codemod check: timers must not be imported at all\nif grep -rn \"k6/experimental/timers\" . --include='*.js'; then\n  echo 'setTimeout/setInterval are global - delete the import'; exit 1\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use global setTimeout/setInterval directly in new scripts.","When bundling, externalize k6 imports so bundlers cannot resurrect removed module paths."],"tags":["timers","modules","import","migration","experimental","web-apis"],"backgroundTag":"renamed-module-import","analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}