grafana/k6 · error
call to Blob.[arrayBuffer] failed
Error message
call to Blob.[arrayBuffer] failed: %w
What it means
Thrown by extractBytes when calling arrayBuffer() on an object (a Blob being serialized for send) returns an error instead of a promise value. The method existed (AssertFunction passed) but invoking it failed — e.g. the blob's internal promise rejected or the object is a mock whose arrayBuffer throws. The wrapped cause is included.
Solutions
- Pass a genuine Blob created via new Blob(...), not a hand-rolled object mimicking one
- Inspect the wrapped error for the underlying rejection cause
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at internal/js/modules/k6/websockets/helpers.go:51 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18).
Data as JSON: /api/errors/05f0d3698957102b.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/websockets/helpers.go:51
}
func isBlob(o *sobek.Object, blobConstructor sobek.Value) bool {
return o.Prototype().Get("constructor") == blobConstructor
}
func isObject(val sobek.Value) bool {
return val != nil && val.ExportType() != nil && val.ExportType().Kind() == reflect.Map
}
func extractBytes(o *sobek.Object, rt *sobek.Runtime) []byte {
arrayBuffer, ok := sobek.AssertFunction(o.Get("arrayBuffer"))
if !ok {
common.Throw(rt, errors.New("Blob.[arrayBuffer] is not a function"))
}
buffer, err := arrayBuffer(sobek.Undefined())
if err != nil {
common.Throw(rt, fmt.Errorf("call to Blob.[arrayBuffer] failed: %w", err))
}
p, ok := buffer.Export().(*sobek.Promise)
if !ok {
common.Throw(rt, errors.New("Blob.[arrayBuffer] return is not a Promise"))
}
ab, ok := p.Result().Export().(sobek.ArrayBuffer)
if !ok {
common.Throw(rt, errors.New("Blob.[arrayBuffer] promise's return is not an ArrayBuffer"))
}
return ab.Bytes()
}
View on GitHub (pinned to 01ffac6f24)