{"record":{"id":"12e46d5bf0883a76","repo":"grafana/k6","slug":"attaching-worker-target-id-v-to-session-id-v-w","errorCode":null,"errorMessage":"attaching worker target ID %v to session ID %v: %w","messagePattern":"attaching worker target ID (.+?) to session ID (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/frame_session.go","lineNumber":1140,"sourceCode":"\t\t}\n\t\treturn err\n\t}\n\n\treturn nil\n}\n\n// attachWorkerToTarget attaches a Worker target to a given session.\nfunc (fs *FrameSession) attachWorkerToTarget(ti *target.Info, session *Session) error {\n\tif fs.page.isClosing() {\n\t\tfs.logger.Debugf(\"FrameSession:attachWorkerToTarget\",\n\t\t\t\"rejected worker; page is closing: tid=%v\", ti.TargetID)\n\t\tdetachSession(session)\n\t\treturn nil\n\t}\n\n\tw, err := NewWorker(fs.ctx, session, ti.TargetID, ti.URL)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"attaching worker target ID %v to session ID %v: %w\",\n\t\t\tti.TargetID, session.ID(), err)\n\t}\n\tfs.page.addWorker(session.ID(), w)\n\n\treturn nil\n}\n\nfunc (fs *FrameSession) onDetachedFromTarget(event *target.EventDetachedFromTarget) {\n\tfs.logger.Debugf(\"FrameSession:onDetachedFromTarget\",\n\t\t\"sid:%v tid:%v esid:%v\",\n\t\tfs.session.ID(), fs.targetID, event.SessionID)\n\n\tfs.page.removeWorker(event.SessionID)\n}\n\nfunc (fs *FrameSession) onTargetCrashed() {\n\tfs.logger.Debugf(\"FrameSession:onTargetCrashed\", \"sid:%v tid:%v\", fs.session.ID(), fs.targetID)\n","sourceCodeStart":1122,"sourceCodeEnd":1158,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/frame_session.go#L1122-L1158","documentation":"While handling Target.attachedToTarget for a worker target, NewWorker failed for the worker's target ID and URL. The wrapped error carries the construction failure; the worker cannot be registered to the page and the attach is aborted.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/frame_session.go:1082 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped error for the worker construction failure","Check the page's web workers for crashes or unusual types","Update k6 and retry"],"exampleFix":null,"handlingStrategy":"try-catch","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"}