{"record":{"id":"aa381477f6566271","repo":"grafana/k6","slug":"disposing-element-with-id-s-w","errorCode":null,"errorMessage":"disposing element with ID %s: %w","messagePattern":"disposing element with ID (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/js_handle.go","lineNumber":114,"sourceCode":"\n\t// We do not want to return an error when the error is a closed\n\t// context. The reason the context would be closed is due to the\n\t// iteration ending and therefore the associated browser and its assets\n\t// will be automatically deleted.\n\tif errors.Is(err, context.Canceled) {\n\t\th.logger.Debugf(\"BaseJSHandle:Dispose\", \"%v\", err)\n\t\treturn nil\n\t}\n\t// The following error indicates that the object we're trying to release\n\t// cannot be found, which would mean that the object has already been\n\t// removed/deleted. This can occur when a navigation occurs, usually when\n\t// a page contains an iframe.\n\tif strings.Contains(err.Error(), \"Cannot find context with specified id\") {\n\t\th.logger.Debugf(\"BaseJSHandle:Dispose\", \"%v\", err)\n\t\treturn nil\n\t}\n\n\treturn fmt.Errorf(\"disposing element with ID %s: %w\", h.remoteObject.ObjectID, err)\n}\n\n// dispose sends a command to the browser to release the remote object.\nfunc (h *BaseJSHandle) dispose() error {\n\tif h.disposed {\n\t\treturn nil\n\t}\n\th.disposed = true\n\tif h.remoteObject.ObjectID == \"\" {\n\t\treturn nil\n\t}\n\tact := runtime.ReleaseObject(h.remoteObject.ObjectID)\n\tif err := act.Do(cdp.WithExecutor(h.ctx, h.session)); err != nil {\n\t\treturn fmt.Errorf(\"disposing element with ID %s: %w\",\n\t\t\th.remoteObject.ObjectID, err)\n\t}\n\n\treturn nil","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/browser/common/js_handle.go#L96-L132","documentation":"Wrap of the CDP Runtime.releaseObject command in BaseJSHandle.Dispose: when a handle is disposed and its remote object has an ID, k6 asks the browser to free the remote object; this wrap reports the object ID whose release failed. Context-canceled errors are deliberately swallowed (iteration teardown), so this error surfaces for real failures such as the object already being gone after navigation or the session being closed for another reason.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/js_handle.go:114 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Usually safe to ignore when it occurs during page navigation or teardown — the object is already released","Avoid holding JSHandle/ElementHandle references across navigations","Call dispose() before the page navigates away if explicit cleanup matters","Update k6; newer builds tolerate already-released objects more gracefully"],"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"}