{"record":{"id":"80c00a268b1f8bdd","repo":"grafana/k6","slug":"parsing-scrollintoviewifneeded-options-w","errorCode":null,"errorMessage":"parsing scrollIntoViewIfNeeded options: %w","messagePattern":"parsing scrollIntoViewIfNeeded options: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/element_handle_mapping.go","lineNumber":193,"sourceCode":"\t\t\tif err := popts.Parse(vu.Context(), opts); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing element handle screenshot options: %w\", err)\n\t\t\t}\n\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\tbb, err := eh.Screenshot(popts, vu.filePersister)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err //nolint:wrapcheck\n\t\t\t\t}\n\n\t\t\t\tab := rt.NewArrayBuffer(bb)\n\n\t\t\t\treturn &ab, nil\n\t\t\t}), nil\n\t\t},\n\t\t\"scrollIntoViewIfNeeded\": func(opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tpopts := common.NewElementHandleBaseOptions(eh.DefaultTimeout())\n\t\t\tif err := popts.Parse(vu.Context(), opts); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing scrollIntoViewIfNeeded options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, eh.ScrollIntoViewIfNeeded(popts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"selectOption\": func(values sobek.Value, opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tconvValues, err := ConvertSelectOptionValues(vu.Runtime(), values)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing select options values: %w\", err)\n\t\t\t}\n\t\t\tpopts := common.NewElementHandleBaseOptions(eh.DefaultTimeout())\n\t\t\tif err := popts.Parse(vu.Context(), opts); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing selectOption options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn eh.SelectOption(convValues, popts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/browser/element_handle_mapping.go#L175-L211","documentation":"Thrown synchronously by ElementHandle.scrollIntoViewIfNeeded() when its options fail to parse. The method parses common.ElementHandleBaseOptions (force, noWaitAfter, timeout), whose Parse in common/element_handle_options.go is lenient coercion and always returns nil, making this wrap defensive and effectively unreachable in current k6.","triggerScenarios":"In current code none: any values for force/noWaitAfter/timeout coerce and unknown keys are ignored. Older xk6-browser builds with structural base-option parsing could raise it.","commonSituations":"Porting Playwright scripts that pass extra scroll options (block/inline are NOT supported here and are silently ignored, unlike Playwright's scrollIntoViewIfNeeded); mistaking a later 'element is not in the viewport' timeout inside the promise for this parse error.","solutions":["Use only { force, noWaitAfter, timeout } with a numeric millisecond timeout","Do not pass block/inline alignment options; they are unsupported for this API in k6","Upgrade k6 if the message appears, since current Parse cannot fail","Read the wrapped cause after the colon to find the failing field"],"exampleFix":"// before\nawait el.scrollIntoViewIfNeeded({ block: 'center', timeout: '5s' });\n\n// after\nawait el.scrollIntoViewIfNeeded({ timeout: 5000 });","handlingStrategy":"try-catch","validationCode":"const ALLOWED = new Set(['force', 'noWaitAfter', 'timeout']);\nconst bad = Object.keys(opts || {}).filter(k => !ALLOWED.has(k));\nif (bad.length) console.warn(`scrollIntoViewIfNeeded(): unsupported options ignored: ${bad.join(', ')}`);\nif (opts?.timeout !== undefined && !Number.isFinite(Number(opts.timeout))) {\n  throw new Error('scrollIntoViewIfNeeded(): timeout must be ms number');\n}","typeGuard":"function isScrollOpts(o) {\n  if (o == null) return true;\n  return (o.force === undefined || typeof o.force === 'boolean') &&\n         (o.noWaitAfter === undefined || typeof o.noWaitAfter === 'boolean') &&\n         (o.timeout === undefined || Number.isFinite(o.timeout));\n}","tryCatchPattern":"try {\n  await el.scrollIntoViewIfNeeded(opts);\n} catch (e) {\n  if (/parsing scrollIntoViewIfNeeded options/.test(String(e.message))) {\n    console.log(`fix options: ${e.message}`);\n  } else throw e; // e.g. timeout waiting for visibility happens inside the promise\n}","preventionTips":["k6 does not support Playwright's block/inline alignment options here; they are ignored","Keep timeout numeric; '5s' coerces to a wrong duration without any error","Current k6 cannot raise this parse error; treat occurrence as a version signal"],"tags":["k6","browser","element-handle","scroll","option-parsing"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}