grafana/k6 · error

invalid maxReceiveSize value: '%#v', it needs to be an integ

Error message

invalid maxReceiveSize value: '%#v', it needs to be an integer

What it means

maxReceiveSize in client.connect() params caps the message size in bytes the client accepts and must be an integer (a JS number that exports to int64); 0 keeps the default (no explicit limit, params.go:142). Strings ('1024') and non-integer numbers (1024.5) fail the type assertion and throw 'invalid maxReceiveSize value ... needs to be an integer'.

Source

Thrown at internal/js/modules/k6/grpc/params.go:188

			}
		case "reflect":
			var ok bool
			result.UseReflectionProtocol, ok = v.(bool)
			if !ok {
				return result, fmt.Errorf("invalid reflect value: '%#v', it needs to be boolean", v)
			}
		case "reflectMetadata":
			md, err := newMetadata(params.Get(k))
			if err != nil {
				return result, fmt.Errorf("invalid reflectMetadata param: %w", err)
			}

			result.ReflectionMetadata = md
		case "maxReceiveSize":
			var ok bool
			result.MaxReceiveSize, ok = v.(int64)
			if !ok {
				return result, fmt.Errorf("invalid maxReceiveSize value: '%#v', it needs to be an integer", v)
			}
			if result.MaxReceiveSize < 0 {
				return result, fmt.Errorf("invalid maxReceiveSize value: '%#v, it needs to be a positive integer", v)
			}
		case "maxSendSize":
			var ok bool
			result.MaxSendSize, ok = v.(int64)
			if !ok {
				return result, fmt.Errorf("invalid maxSendSize value: '%#v', it needs to be an integer", v)
			}
			if result.MaxSendSize < 0 {
				return result, fmt.Errorf("invalid maxSendSize value: '%#v, it needs to be a positive integer", v)
			}
		case "tls":
			if err := parseConnectTLSParam(result, v); err != nil {
				return result, err
			}
		case "authority":

View on GitHub (pinned to 93accf6570)

Solutions

  1. Pass an integer number of bytes: 4194304
  2. parseInt env/config strings before passing
  3. Remember 0 means no explicit limit

Example fix

// before
client.connect(addr, { maxReceiveSize: '4194304' });

// after
client.connect(addr, { maxReceiveSize: 4194304 });
Defensive patterns

Strategy: validation

Validate before calling

if (connectParams.maxReceiveSize !== undefined &&
    !(typeof connectParams.maxReceiveSize === 'number' && Number.isInteger(connectParams.maxReceiveSize))) {
  throw new Error(`maxReceiveSize must be an integer, got ${connectParams.maxReceiveSize}`);
}
client.connect(addr, connectParams);

Type guard

function isByteSize(v) {
  return typeof v === 'number' && Number.isInteger(v) && v >= 0;
}

Prevention

When it happens

Trigger: connect(addr, { maxReceiveSize: '4194304' }); { maxReceiveSize: 3.5 }; values read from JSON/YAML config that were quoted.

Common situations: Config systems that stringify numbers; unit confusion (the value is raw bytes, not KB); raising limits to accommodate large response payloads.

Related errors


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