{"record":{"id":"dd7112ef1e1035f0","repo":"grafana/k6","slug":"w","errorCode":null,"errorMessage":"%w","messagePattern":"%w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/keyboard.go","lineNumber":347,"sourceCode":"\t\t\t\treturn fmt.Errorf(\"pressing key: %w\", err)\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\tif err := k.insertText(string(c)); err != nil {\n\t\t\treturn fmt.Errorf(\"inserting text: %w\", err)\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc wait(ctx context.Context, delay int64) error {\n\tt := time.NewTimer(time.Duration(delay) * time.Millisecond)\n\tselect {\n\tcase <-ctx.Done():\n\t\tif !t.Stop() {\n\t\t\t<-t.C\n\t\t}\n\t\treturn fmt.Errorf(\"%w\", ContextErr(ctx))\n\tcase <-t.C:\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":329,"sourceCodeEnd":353,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/browser/common/keyboard.go#L329-L353","documentation":"Returned by wait when the browser operation's context is canceled or its deadline expires before the timer elapses; it wraps the context error (context.Canceled or context.DeadlineExceeded) so callers can identify cancellation rather than a timeout of the operation itself.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/keyboard.go:347 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check errors.Is(err, context.Canceled) or errors.Is(err, context.DeadlineExceeded) to distinguish cancellation from other failures","Ensure the k6 iteration/browser context timeout is large enough for the delay passed to wait","Avoid calling keyboard APIs with delays that exceed the remaining context lifetime"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}