grafana/k6 · error

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

Error message

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

What it means

maxSendSize in client.connect() params caps the request message size in bytes and must be an integer JS number (int64 after export); 0 keeps the default. Strings and non-integer numbers fail with 'invalid maxSendSize value ... needs to be an integer'.

Source

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

			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":
			var ok bool
			result.Authority, ok = v.(string)
			if !ok {
				return result, fmt.Errorf("invalid authority value: '%#v', it needs to be a string", v)
			}
		default:
			return result, fmt.Errorf("unknown connect param: %q", k)
		}
	}

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, { maxSendSize: '4194304' });

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

Strategy: validation

Validate before calling

if (connectParams.maxSendSize !== undefined &&
    !(typeof connectParams.maxSendSize === 'number' && Number.isInteger(connectParams.maxSendSize))) {
  throw new Error(`maxSendSize must be an integer, got ${connectParams.maxSendSize}`);
}
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, { maxSendSize: '1024' }); { maxSendSize: 1.5 }; quoted numbers coming from JSON/YAML config.

Common situations: Sending large request payloads (blobs, batched messages) and raising limits from config files that stringify values.

Related errors


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