grafana/k6 · error
parsing setContent options: %w
Error message
parsing setContent options: %w
What it means
FrameSetContentOptions.Parse (frame_options.go:537) validates the `waitUntil` option of frame.setContent()/page.setContent() through LifecycleEvent.UnmarshalText. Acceptable values are only "load", "domcontentloaded" and "networkidle"; anything else fails and is wrapped with this message before any content is set. Like goto, this is local validation, not a Chromium error.
Source
Thrown at internal/js/modules/k6/browser/common/frame_options.go:537
Timeout: defaultTimeout,
WaitUntil: LifecycleEventLoad,
}
}
// Parse parses the frame setContent options.
func (o *FrameSetContentOptions) Parse(ctx context.Context, opts sobek.Value) error {
rt := k6ext.Runtime(ctx)
if !common.IsNullish(opts) {
opts := opts.ToObject(rt)
for _, k := range opts.Keys() {
switch k {
case "timeout":
o.Timeout = time.Duration(opts.Get(k).ToInteger()) * time.Millisecond
case "waitUntil":
lifeCycle := opts.Get(k).String()
if err := o.WaitUntil.UnmarshalText([]byte(lifeCycle)); err != nil {
return fmt.Errorf("parsing setContent options: %w", err)
}
}
}
}
return nil
}
// NewFrameSetInputFilesOptions creates a new FrameSetInputFilesOptions.
func NewFrameSetInputFilesOptions(defaultTimeout time.Duration) *FrameSetInputFilesOptions {
return &FrameSetInputFilesOptions{
ElementHandleSetInputFilesOptions: *NewElementHandleSetInputFilesOptions(defaultTimeout),
Strict: false,
}
}
// Parse parses FrameSetInputFilesOptions from sobek.Value.
func (o *FrameSetInputFilesOptions) Parse(ctx context.Context, opts sobek.Value) error {View on GitHub (pinned to 93accf6570)
Solutions
- Change the waitUntil value to "load", "domcontentloaded" or "networkidle"
- Centralize lifecycle constants in your script so config-driven values cannot drift from the supported set
- Check for typos and casing — matching is exact and lowercase
Example fix
// before
page.setContent('<h1>hi</h1>', { waitUntil: 'NetworkIdle' });
// after
page.setContent('<h1>hi</h1>', { waitUntil: 'networkidle' }); Defensive patterns
Strategy: validation
Validate before calling
const WAIT_UNTIL = ['load', 'domcontentloaded', 'networkidle'];
if (opts && opts.waitUntil !== undefined && !WAIT_UNTIL.includes(opts.waitUntil)) {
throw new Error(`invalid waitUntil: ${opts.waitUntil}`);
}
page.setContent(html, opts); Type guard
function isWaitUntil(v: unknown): v is 'load' | 'domcontentloaded' | 'networkidle' {
return typeof v === 'string' && ['load', 'domcontentloaded', 'networkidle'].includes(v);
} Prevention
- Only timeout and waitUntil are parsed for setContent — do not pass other keys expecting effect
- Validate config-driven option strings before the run, not during
When it happens
Trigger: page.setContent(html, { waitUntil: ... }) with unsupported or misspelled values such as 'load-complete', 'NetworkIdle', 'domcontent-loaded', or 'idle'. Only "timeout" and "waitUntil" keys are honored by this parser.
Common situations: Porting setContent calls from Playwright where extra waitUntil values exist, or generating options dynamically with unvalidated strings from config files/environment variables.
Related errors
- parsing goto options: %w
- parsing waitForNavigation options: %w
- parsing waitForURL options: %w
- wrong polling option value: %q; possible values: "raf", "mut
- %q is not a valid DOM state
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/3cd495a8c458907f.
Report an issue: GitHub.