grafana/k6 · error
got error while trying to export ArrayBufferView to bytes: %
Error message
got error while trying to export ArrayBufferView to bytes: %w
What it means
Wrap of a Sobek export failure in send(): the argument passed the ArrayBuffer.isView check, but converting the typed-array view (Uint8Array, DataView, etc.) into Go []byte via rt.ExportTo failed. This indicates the value's internal structure is not a valid view over an ArrayBuffer at export time — usually the buffer was detached or a non-standard object tricked the isView check.
Source
Thrown at internal/js/modules/k6/websockets/websockets.go:691
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))
}
var b []byte
err = rt.ExportTo(msg, &b)
if err != nil {
common.Throw(rt,
fmt.Errorf("got error while trying to export ArrayBufferView to bytes: %w", err))
}
w.bufferedAmount += len(b)
w.writeQueueCh <- message{
mtype: websocket.BinaryMessage,
data: b,
t: time.Now(),
}
}
}
func (w *webSocket) sendArrayBuffer(o sobek.ArrayBuffer) {
b := o.Bytes()
w.bufferedAmount += len(b)
w.writeQueueCh <- message{
mtype: websocket.BinaryMessage,
data: b,
t: time.Now(),
}View on GitHub (pinned to 165bb3c1a4)
Solutions
- Send a copy of the data instead of a view over a detached/transferred buffer
- Construct a fresh Uint8Array from the data before sending
- Fall back to sending a string or Blob if the view keeps failing to export
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at internal/js/modules/k6/websockets/websockets.go:666 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/0534a1f226e5e60a.
Report an issue: GitHub.