{"record":{"id":"c620b04748eece03","repo":"grafana/k6","slug":"delay-must-be-an-integer-got-s","errorCode":null,"errorMessage":"delay must be an integer, got %s","messagePattern":"delay must be an integer, got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/mouse_mapping.go","lineNumber":89,"sourceCode":"\tobj := opts.ToObject(rt)\n\tfor _, k := range obj.Keys() {\n\t\tv := obj.Get(k)\n\t\tswitch k {\n\t\tcase \"button\":\n\t\t\tpopts.Button = v.String()\n\t\tcase \"clickCount\":\n\t\t\tswitch v.ExportType().Kind() {\n\t\t\tcase reflect.Int64:\n\t\t\t\tpopts.ClickCount = v.ToInteger()\n\t\t\tdefault:\n\t\t\t\treturn nil, fmt.Errorf(\"clickCount must be an integer, got %s\", v.ExportType().Kind())\n\t\t\t}\n\t\tcase \"delay\":\n\t\t\tswitch v.ExportType().Kind() {\n\t\t\tcase reflect.Int64:\n\t\t\t\tpopts.Delay = v.ToInteger()\n\t\t\tdefault:\n\t\t\t\treturn nil, fmt.Errorf(\"delay must be an integer, got %s\", v.ExportType().Kind())\n\t\t\t}\n\t\t}\n\t}\n\n\treturn popts, nil\n}\n\n// parseMouseDblClickOptions parses the mouse double click options from a Sobek value.\nfunc parseMouseDblClickOptions(rt *sobek.Runtime, opts sobek.Value) (*common.MouseDblClickOptions, error) {\n\tpopts := common.NewMouseDblClickOptions()\n\tif k6common.IsNullish(opts) {\n\t\treturn popts, nil\n\t}\n\n\tobj := opts.ToObject(rt)\n\tfor _, k := range obj.Keys() {\n\t\tv := obj.Get(k)\n\t\tswitch k {","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/browser/browser/mouse_mapping.go#L71-L107","documentation":"Thrown by parseMouseClickOptions (browser/mouse_mapping.go:89) when mouse.click's 'delay' option is not an Int64 kind. Delay (milliseconds between mousedown and mouseup) must be an integer; strings, floats, and booleans are rejected with this message naming the offending reflect.Kind.","triggerScenarios":"page.mouse().click(10, 20, { delay: '100' }), { delay: 100.5 }, or { delay: false }. Computed pacing delays that produce fractions are the most common source.","commonSituations":"Delay from environment variables or JSON scenario config (string-typed); think-time budgets divided across actions yielding floats; delay copied from HTTP response timings.","solutions":["Use an integer literal: { delay: 100 }.","Round computed delays: { delay: Math.round(thinkTimeMs) }.","Coerce config values: Number(cfg.delay) with an integer check.","Omit delay for an immediate click (delay 0)."],"exampleFix":"// before\nawait page.mouse().click(10, 20, { delay: thinkTime / 3 }); // 33.33\n\n// after\nawait page.mouse().click(10, 20, { delay: Math.round(thinkTime / 3) });","handlingStrategy":"type-guard","validationCode":"if (opts?.delay != null && !Number.isInteger(opts.delay)) throw new Error(`delay must be an integer, got ${typeof opts.delay}`);\nawait page.mouse().click(x, y, opts);","typeGuard":"function isIntegerOption(o, key) {\n  return o == null || o[key] == null || Number.isInteger(o[key]);\n}","tryCatchPattern":"try { await page.mouse().click(x, y, opts); } catch (e) { if (/delay must be an integer/.test(e.message)) { await page.mouse().click(x, y, { ...opts, delay: Math.round(Number(opts.delay)) }); } else throw e; }","preventionTips":["Use integer millisecond literals for delay.","Math.round any computed think-time delay.","Convert env/config strings with Number() and verify integer-ness."],"tags":["k6","browser","mouse","delay","integer-validation"],"backgroundTag":"invalid-options-argument","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"}