grafana/k6 · error
got error while trying to check if argument is ArrayBufferVi
Error message
got error while trying to check if argument is ArrayBufferView: %w
What it means
Wrap of a Sobek runtime failure in send()'s default branch: before deciding whether the argument is an ArrayBufferView, k6 invokes the script's ArrayBuffer.isView function inside rt.Try. The wrapped error means that lookup/call itself threw — the ArrayBuffer global or its isView method was replaced or shadowed by script code — not that the argument type is wrong.
Source
Thrown at internal/js/modules/k6/websockets/websockets.go:681
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))
}
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(),
}
}View on GitHub (pinned to 165bb3c1a4)
Solutions
- Do not override, delete, or shadow the global ArrayBuffer object in the script
- Check for script-side polyfills or mocks that replace built-in constructors
- Send data as a plain string or Blob to bypass the ArrayBufferView check
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at internal/js/modules/k6/websockets/websockets.go:656 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/6667a6f6a5184c78.
Report an issue: GitHub.