grafana/k6 · error
missing required argument 'url'
Error message
missing required argument 'url'
What it means
Thrown by mapWaitForURL (internal/js/modules/k6/browser/browser/page_mapping.go:969), the shared implementation of page.waitForURL() and frame.waitForURL(). The url argument is mandatory and must be a glob-style string or a RegExp (parsed by parseStringOrRegex); the nullish guard fails the call before the wait promise is even created, because there is nothing to match the navigation URL against.
Solutions
- Pass a glob string or RegExp: await page.waitForURL('**/dashboard'), await page.waitForURL(/\/dashboard\?session=.+/)
- Default dynamic patterns: const target = __ENV.TARGET_URL ?? '**/dashboard'
- If you only need a timeout, pass it as the second argument: page.waitForURL('**/dashboard', { timeout: 5000 })
- Log the pattern before the call to find where it becomes undefined
Example fix
// before
await page.waitForURL(__ENV.EXPECTED_PATH); // env var not set -> undefined
// after
await page.waitForURL(__ENV.EXPECTED_PATH ?? '**/dashboard', { timeout: 10_000 }); Defensive patterns
Strategy: validation
Validate before calling
const target = __ENV.EXPECTED_PATH ?? '**/dashboard';
if (target === undefined || target === null) throw new Error('url is required');
await page.waitForURL(target, { timeout: 10_000 }); Type guard
function isGlobOrRegex(v) {
return (typeof v === 'string' && v.length > 0) || v instanceof RegExp;
}
// usage: if (!isGlobOrRegex(target)) throw new Error('waitForURL needs a glob string or RegExp'); Try / catch
try {
await page.waitForURL(target);
} catch (e) {
if (/missing required argument 'url'/.test(e.message)) throw new Error('waitForURL called without a URL pattern');
throw e;
} Prevention
- Always pass a glob string or RegExp as the first argument; options go second
- Default env-driven URL patterns with ?? instead of trusting __ENV
- Set a realistic timeout via the second argument rather than omitting the first
- Use editor typings so the missing first argument is flagged
When it happens
Trigger: Calling page.waitForURL() with zero arguments; passing undefined/null explicitly; passing a URL pattern built from a template variable that is undefined (missing env var, absent config key), or passing options as the first argument by mistake.
Common situations: Waiting on a redirect target read from __ENV or options that was never set; ports of Playwright's page.waitForURL where the pattern got dropped; passing an options object first ({ timeout: 5000 }) instead of the URL.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- missing required argument 'altText'
- missing required argument 'label'
- missing required argument 'placeholder'
- missing required argument 'placeholder'
- missing required argument 'role'
AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18).
Data as JSON: /api/errors/3a902cd02c139ddd.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/browser/page_mapping.go:969
if err != nil {
return fmt.Errorf("page.route('%s'): %w", path, err)
}
return nil
}
return promise(vu, func() (any, error) {
return nil, p.Route(ppath, route, newRegExMatcher(ctx, vu, tq))
}), nil
}
}
func mapWaitForURL(vu moduleVU, target interface {
Timeout() time.Duration
WaitForURL(urlPattern string, opts *common.FrameWaitForURLOptions, rm common.RegExMatcher) error
}, url sobek.Value, opts sobek.Value,
) (*sobek.Promise, error) {
if k6common.IsNullish(url) {
return nil, errors.New("missing required argument 'url'")
}
popts := common.NewFrameWaitForURLOptions(target.Timeout())
if err := popts.Parse(vu.Context(), opts); err != nil {
return nil, fmt.Errorf("parsing waitForURL options: %w", err)
}
purl := parseStringOrRegex(url, false)
tq, ctx, stop := newTaskQueue(vu)
return promise(vu, func() (result any, reason error) {
defer stop()
return nil, target.WaitForURL(purl, popts, newRegExMatcher(ctx, vu, tq))
}), nil
}
func mapWaitForNavigation(vu moduleVU, target interface {
Timeout() time.Duration
WaitForNavigation(*common.FrameWaitForNavigationOptions, common.RegExMatcher) (*common.Response, error)View on GitHub (pinned to 01ffac6f24)