grafana/k6 · error

unknown binaryType %s, the supported ones are "blob" and "ar

Error message

unknown binaryType %s, the supported ones are "blob" and "arraybuffer"

What it means

A default-branch guard in the WebSocket message handler: an incoming binary frame arrived, but the socket's binaryType property holds a value other than the two supported strings "blob" and "arraybuffer". Because binaryType is defined as an accessor that validates on assignment, reaching this default case normally means the internal state was mutated unexpectedly rather than through the public property setter.

Source

Thrown at internal/js/modules/k6/websockets/websockets.go:230

			return rt.ToValue((uint)(w.readyState))
		}), nil, sobek.FLAG_FALSE, sobek.FLAG_TRUE))
	must(rt, w.obj.DefineAccessorProperty(
		"bufferedAmount", rt.ToValue(func() sobek.Value { return rt.ToValue(w.bufferedAmount) }), nil,
		sobek.FLAG_FALSE, sobek.FLAG_TRUE))
	must(rt, w.obj.DefineAccessorProperty("extensions",
		rt.ToValue(func() sobek.Value { return rt.ToValue(w.extensions) }), nil, sobek.FLAG_FALSE, sobek.FLAG_TRUE))
	must(rt, w.obj.DefineAccessorProperty(
		"protocol", rt.ToValue(func() sobek.Value { return rt.ToValue(w.protocol) }), nil, sobek.FLAG_FALSE, sobek.FLAG_TRUE))
	must(rt, w.obj.DefineAccessorProperty(
		"binaryType", rt.ToValue(func() sobek.Value {
			return rt.ToValue(w.binaryType)
		}), rt.ToValue(func(s string) error {
			switch s {
			case blobBinaryType, arraybufferBinaryType:
				w.binaryType = s
				return nil
			default:
				return fmt.Errorf(`unknown binaryType %s, the supported ones are "blob" and "arraybuffer"`, s)
			}
		}), sobek.FLAG_FALSE, sobek.FLAG_TRUE))

	setOn := func(property string, el *eventListener) {
		if el == nil {
			// this is generally should not happen, but we're being defensive
			common.Throw(rt, fmt.Errorf("not supported on-handler '%s'", property))
		}

		must(rt, w.obj.DefineAccessorProperty(
			property, rt.ToValue(func() sobek.Value {
				return rt.ToValue(el.getOn)
			}), rt.ToValue(func(call sobek.FunctionCall) sobek.Value {
				arg := call.Argument(0)

				// it's possible to unset handlers by setting them to null
				if common.IsNullish(arg) {
					el.setOn(nil)

View on GitHub (pinned to 165bb3c1a4)

Solutions

  1. Set ws.binaryType explicitly to "arraybuffer" or "blob" (the default) before receiving binary messages
  2. Do not attempt to override or delete the binaryType property on the WebSocket object
  3. Update k6 to a recent version in case earlier builds allowed invalid binaryType values
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/js/modules/k6/websockets/websockets.go:219 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@165bb3c1a4 (2026-08-18). Data as JSON: /api/errors/77fd3190d77baf28. Report an issue: GitHub.