{"record":{"id":"472e80e4c633dbe9","repo":"grafana/k6","slug":"executing-page-on-s-handler-w","errorCode":null,"errorMessage":"executing page.on('%s') handler: %w","messagePattern":"executing page\\.on\\('(.+?)'\\) handler: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/page_mapping.go","lineNumber":802,"sourceCode":"\t\t\tcommon.PageEventMetric:          {mapp: mapMetricEvent, wait: true},\n\t\t\tcommon.PageEventRequest:         {mapp: mapRequestEvent},\n\t\t\tcommon.PageEventResponse:        {mapp: mapResponseEvent},\n\t\t\tcommon.PageEventRequestFinished: {mapp: mapRequestEvent},\n\t\t\tcommon.PageEventRequestFailed:   {mapp: mapRequestEvent},\n\t\t}\n\t\tpageEvent, ok := pageEvents[eventName]\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unknown page on event: %q\", eventName)\n\t\t}\n\n\t\tctx := vu.Context()\n\t\ttq := vu.get(ctx, p.TargetID())\n\n\t\treturn p.On(eventName, func(event common.PageEvent) error {\n\t\t\twait := queueTask(ctx, tq, func() (sobek.Value, error) {\n\t\t\t\t_, err := handle(sobek.Undefined(), vu.Runtime().ToValue(pageEvent.mapp(vu, event)))\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"executing page.on('%s') handler: %w\", eventName, err)\n\t\t\t\t}\n\t\t\t\treturn nil, nil\n\t\t\t})\n\t\t\tif pageEvent.wait {\n\t\t\t\tif _, err := wait(); errors.Is(err, context.Canceled) {\n\t\t\t\t\treturn errors.New(\"iteration ended before page.on handler completed executing\")\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn nil\n\t\t})\n\t}\n}\n\nfunc parseWaitForFunctionArgs(\n\tctx context.Context, timeout time.Duration, pageFunc, opts sobek.Value, gargs ...sobek.Value,\n) (string, *common.FrameWaitForFunctionOptions, []any, error) {\n\tpopts := common.NewFrameWaitForFunctionOptions(timeout)\n\terr := popts.Parse(ctx, opts)","sourceCodeStart":784,"sourceCodeEnd":820,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/browser/page_mapping.go#L784-L820","documentation":"Error \"executing page.on('%s') handler: %w\" thrown in grafana/k6.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/browser/page_mapping.go:802 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}