grafana/k6 · info

parsing frame dispatch event options: %w

Error message

parsing frame dispatch event options: %w

What it means

Options passed to frame.dispatchEvent(selector, type, eventInit, opts) failed to parse (frame_mapping.go:64). FrameDispatchEventOptions embeds *FrameBaseOptions, whose Parse only reads 'strict' and 'timeout' and always returns nil in this codebase - so this branch is defensive and effectively unreachable in the current version; hitting it indicates an internal k6 regression or a modified option parser.

Source

Thrown at internal/js/modules/k6/browser/browser/frame_mapping.go:64

		},
		"content": func() *sobek.Promise {
			return promise(vu, func() (any, error) {
				return f.Content() //nolint:wrapcheck
			})
		},
		"dblclick": func(selector string, opts sobek.Value) (*sobek.Promise, error) {
			popts := common.NewFrameDblClickOptions(f.Timeout())
			if err := popts.Parse(vu.Context(), opts); err != nil {
				return nil, fmt.Errorf("parsing double click options: %w", err)
			}
			return promise(vu, func() (any, error) {
				return nil, f.Dblclick(selector, popts) //nolint:wrapcheck
			}), nil
		},
		"dispatchEvent": func(selector, typ string, eventInit, opts sobek.Value) (*sobek.Promise, error) {
			popts := common.NewFrameDispatchEventOptions(f.Timeout())
			if err := popts.Parse(vu.Context(), opts); err != nil {
				return nil, fmt.Errorf("parsing frame dispatch event options: %w", err)
			}
			earg := exportArg(eventInit)
			return promise(vu, func() (any, error) {
				return nil, f.DispatchEvent(selector, typ, earg, popts) //nolint:wrapcheck
			}), nil
		},
		"evaluate": func(pageFunc sobek.Value, gargs ...sobek.Value) (*sobek.Promise, error) {
			if sobekEmptyString(pageFunc) {
				return nil, fmt.Errorf("evaluate requires a page function")
			}
			funcString := pageFunc.String()
			gopts := exportArgs(gargs)
			return promise(vu, func() (any, error) {
				return f.Evaluate(funcString, gopts...)
			}), nil
		},
		"evaluateHandle": func(pageFunc sobek.Value, gargs ...sobek.Value) (*sobek.Promise, error) {
			if sobekEmptyString(pageFunc) {

View on GitHub (pinned to 93accf6570)

Solutions

  1. Pass a plain options object with only supported keys: { timeout: 5000, strict: true }
  2. Reproduce on the latest stable k6; if it still fires, open an issue with the script and k6 version
  3. Pin/downgrade to a known-good k6 version while investigating
Defensive patterns

Strategy: try-catch

Validate before calling

const safeOpts = opts == null ? {} : { timeout: Number(opts.timeout) || undefined, strict: !!opts.strict };

Try / catch

try {
  await frame.dispatchEvent(sel, type, eventInit, safeOpts);
} catch (e) {
  console.error(`dispatchEvent(${type}) on ${sel} failed: ${e.message}`);
}

Prevention

When it happens

Trigger: No user input triggers it in this version: dispatchEvent options ({ timeout, strict }) never produce a parse error. It would only fire if a k6 upgrade made FrameBaseOptions.Parse type-sensitive.

Common situations: Almost never seen in practice; if reported, it usually accompanies a custom k6 fork or an unreleased change to the option parsers.

Related errors


AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15). Data as JSON: /api/errors/56e54032ca79f618. Report an issue: GitHub.