{"record":{"id":"05f0d3698957102b","repo":"grafana/k6","slug":"call-to-blob-arraybuffer-failed-w","errorCode":null,"errorMessage":"call to Blob.[arrayBuffer] failed: %w","messagePattern":"call to Blob\\.\\[arrayBuffer\\] failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/websockets/helpers.go","lineNumber":51,"sourceCode":"}\n\nfunc isBlob(o *sobek.Object, blobConstructor sobek.Value) bool {\n\treturn o.Prototype().Get(\"constructor\") == blobConstructor\n}\n\nfunc isObject(val sobek.Value) bool {\n\treturn val != nil && val.ExportType() != nil && val.ExportType().Kind() == reflect.Map\n}\n\nfunc extractBytes(o *sobek.Object, rt *sobek.Runtime) []byte {\n\tarrayBuffer, ok := sobek.AssertFunction(o.Get(\"arrayBuffer\"))\n\tif !ok {\n\t\tcommon.Throw(rt, errors.New(\"Blob.[arrayBuffer] is not a function\"))\n\t}\n\n\tbuffer, err := arrayBuffer(sobek.Undefined())\n\tif err != nil {\n\t\tcommon.Throw(rt, fmt.Errorf(\"call to Blob.[arrayBuffer] failed: %w\", err))\n\t}\n\n\tp, ok := buffer.Export().(*sobek.Promise)\n\tif !ok {\n\t\tcommon.Throw(rt, errors.New(\"Blob.[arrayBuffer] return is not a Promise\"))\n\t}\n\n\tab, ok := p.Result().Export().(sobek.ArrayBuffer)\n\tif !ok {\n\t\tcommon.Throw(rt, errors.New(\"Blob.[arrayBuffer] promise's return is not an ArrayBuffer\"))\n\t}\n\n\treturn ab.Bytes()\n}\n","sourceCodeStart":33,"sourceCodeEnd":66,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/websockets/helpers.go#L33-L66","documentation":"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.","triggerScenarios":"Thrown at internal/js/modules/k6/websockets/helpers.go:51 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}