grafana/k6 · error
unsupported send type %T
Error message
unsupported send type %T
What it means
Type guard in the WebSocket send path: the argument exported to Go as a map[string]any (a plain JS object) was checked against the Blob constructor and is not a Blob. send() only accepts string, ArrayBuffer, ArrayBuffer views, and Blob instances, so any other object type (plain object, class instance, number, boolean) reaching this branch is rejected, mirroring the browser's TypeError for unsupported send data.
Source
Thrown at internal/js/modules/k6/websockets/websockets.go:666
w.assertStateOpen()
switch o := msg.Export().(type) {
case string:
w.bufferedAmount += len(o)
w.writeQueueCh <- message{
mtype: websocket.TextMessage,
data: []byte(o),
t: time.Now(),
}
case *sobek.ArrayBuffer:
w.sendArrayBuffer(*o)
case sobek.ArrayBuffer:
w.sendArrayBuffer(o)
case map[string]any:
rt := w.vu.Runtime()
obj := msg.ToObject(rt)
if !isBlob(obj, w.blobConstructor) {
common.Throw(rt, fmt.Errorf("unsupported send type %T", o))
}
b := extractBytes(obj, rt)
w.bufferedAmount += len(b)
w.writeQueueCh <- message{
mtype: websocket.BinaryMessage,
data: b,
t: time.Now(),
}
default:
rt := w.vu.Runtime()
isView, err := isArrayBufferView(rt, msg)
if err != nil {
common.Throw(rt,
fmt.Errorf("got error while trying to check if argument is ArrayBufferView: %w", err))
}
if !isView {
common.Throw(rt, fmt.Errorf("unsupported send type %T", o))View on GitHub (pinned to 165bb3c1a4)
Solutions
- Convert the data before sending: JSON.stringify(obj) for text frames
- Wrap binary data in a Blob or ArrayBuffer/TypedArray for binary frames
- Pass primitive strings directly: ws.send('hello')
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at internal/js/modules/k6/websockets/websockets.go:641 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/38dd78617c69686c.
Report an issue: GitHub.