grafana/k6 · error

width must be a number, got %s

Error message

width must be a number, got %s

What it means

Error "width must be a number, got %s" thrown in grafana/k6.

Source

Thrown at internal/js/modules/k6/browser/browser/page_mapping.go:1116

func parseSize(rt *sobek.Runtime, opts sobek.Value) (*common.Size, error) {
	size := &common.Size{}
	if k6common.IsNullish(opts) {
		return size, nil
	}

	obj := opts.ToObject(rt)
	for _, k := range obj.Keys() {
		v := obj.Get(k)
		if k6common.IsNullish(v) {
			continue
		}
		switch k {
		case "width":
			switch v.ExportType().Kind() {
			case reflect.Int64, reflect.Float64:
				size.Width = v.ToFloat()
			default:
				return nil, fmt.Errorf("width must be a number, got %s", v.ExportType().Kind())
			}
		case "height":
			switch v.ExportType().Kind() {
			case reflect.Int64, reflect.Float64:
				size.Height = v.ToFloat()
			default:
				return nil, fmt.Errorf("height must be a number, got %s", v.ExportType().Kind())
			}
		}
	}

	return size, nil
}

// parsePageEmulateMediaOptions parses the page emulate media options from a Sobek value.
//
//nolint:unparam
func parsePageEmulateMediaOptions(

View on GitHub (pinned to 93accf6570)

When it happens

Trigger: Thrown at internal/js/modules/k6/browser/browser/page_mapping.go:1116 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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