{"record":{"id":"081149a55754b2f2","repo":"grafana/k6","slug":"evaluating-handle-for-frame-execution-context-q","errorCode":null,"errorMessage":"evaluating handle for frame: execution context %q not found","messagePattern":"evaluating handle for frame: execution context %q not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/frame.go","lineNumber":919,"sourceCode":"\t}\n\tif exceptionDetails != nil {\n\t\treturn fmt.Errorf(\"%s\", parseExceptionDetails(exceptionDetails))\n\t}\n\n\treturn nil\n}\n\n// EvaluateHandle will evaluate provided page function within an execution context.\nfunc (f *Frame) EvaluateHandle(pageFunc string, args ...any) (handle JSHandleAPI, _ error) {\n\tf.log.Debugf(\"Frame:EvaluateHandle\", \"fid:%s furl:%q\", f.ID(), f.URL())\n\n\tevalHandle := func() (JSHandleAPI, error) {\n\t\tf.executionContextMu.RLock()\n\t\tdefer f.executionContextMu.RUnlock()\n\n\t\tec := f.executionContexts[mainWorld]\n\t\tif ec == nil {\n\t\t\treturn nil, fmt.Errorf(\"evaluating handle for frame: execution context %q not found\", mainWorld)\n\t\t}\n\t\treturn ec.EvalHandle(f.ctx, pageFunc, args...) //nolint:wrapcheck\n\t}\n\n\tf.waitForExecutionContext(mainWorld)\n\thandle, err := evalHandle()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"evaluating handle for frame: %w\", err)\n\t}\n\n\tapplySlowMo(f.ctx)\n\n\treturn handle, nil\n}\n\n// Fill fills out the first element found that matches the selector.\nfunc (f *Frame) Fill(selector, value string, popts *FrameFillOptions) error {\n\tf.log.Debugf(\"Frame:Fill\", \"fid:%s furl:%q sel:%q val:%q\", f.ID(), f.URL(), selector, value)","sourceCodeStart":901,"sourceCodeEnd":937,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/frame.go#L901-L937","documentation":"Returned by Frame.EvaluateHandle when the frame's main-world execution context is absent from the context map after waiting for it. A race where the frame navigated or is tearing down right as the handle evaluation starts; no context means nowhere to evaluate.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/frame.go:911 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry after the frame finishes navigating","Call EvaluateHandle after waitForLoadState","Avoid concurrent navigations with handle evaluations"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}