{"record":{"id":"77ac95e731c771c6","repo":"grafana/k6","slug":"disposing-element-handles-w","errorCode":null,"errorMessage":"disposing element handles: %w","messagePattern":"disposing element handles: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/element_handle.go","lineNumber":1285,"sourceCode":"\t\tevalOptions{forceCallable: true, returnByValue: false},\n\t\tjs.QueryAll,\n\t\tparsedSelector,\n\t)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"querying all selectors %q: %w\", selector, err)\n\t}\n\tif result == nil {\n\t\t// it is ok to return a nil slice because it means we didn't find any elements.\n\t\treturn nil, nil\n\t}\n\n\thandles, ok := result.(JSHandleAPI)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"getting element handle for selector %q: %w\", selector, ErrJSHandleInvalid)\n\t}\n\tdefer func() {\n\t\tif err := handles.Dispose(); err != nil {\n\t\t\terr = fmt.Errorf(\"disposing element handles: %w\", err)\n\t\t\trerr = errors.Join(err, rerr)\n\t\t}\n\t}()\n\n\tprops, err := handles.GetProperties()\n\tif err != nil {\n\t\t// GetProperties has a rich error already, so we don't need to wrap it.\n\t\treturn nil, err //nolint:wrapcheck\n\t}\n\n\ttype indexedElem struct {\n\t\tindex int\n\t\telem  *ElementHandle\n\t}\n\n\tindexedElems := make([]indexedElem, 0, len(props))\n\tfor key, prop := range props {\n\t\tif el := prop.AsElement(); el != nil {","sourceCodeStart":1267,"sourceCodeEnd":1303,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/element_handle.go#L1267-L1303","documentation":"Produced in a deferred cleanup in ElementHandle.queryAll: after obtaining the array-like JSHandle of query results, the code disposes it via handles.Dispose(); if disposal fails the error is wrapped this way and joined with the function's return error via errors.Join. Dispose failures here almost always mean the execution context or target was already destroyed, making cleanup moot.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/element_handle.go:1285 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Treat dispose-during-cleanup failures as benign when the page navigated or closed","Avoid reacting to this error; the primary query error (if any) is joined alongside","Ensure you are not closing the page concurrently with pending queries"],"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"}