{"record":{"id":"bffb4ee170f369a1","repo":"grafana/k6","slug":"failed-to-create-blob-w","errorCode":null,"errorMessage":"failed to create Blob: %w","messagePattern":"failed to create Blob: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/websockets/websockets.go","lineNumber":503,"sourceCode":"\t\t\t\tMetric: w.builtinMetrics.WSMessagesReceived,\n\t\t\t\tTags:   w.tagsAndMeta.Tags,\n\t\t\t},\n\t\t\tTime:     msg.t,\n\t\t\tMetadata: w.tagsAndMeta.Metadata,\n\t\t\tValue:    1,\n\t\t})\n\n\t\trt := w.vu.Runtime()\n\t\tev := w.newEvent(events.MESSAGE, msg.t)\n\n\t\tif msg.mtype == websocket.BinaryMessage {\n\t\t\tvar data any\n\t\t\tswitch w.binaryType {\n\t\t\tcase blobBinaryType:\n\t\t\t\tvar err error\n\t\t\t\tdata, err = rt.New(w.blobConstructor, rt.ToValue([]any{msg.data}))\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"failed to create Blob: %w\", err)\n\t\t\t\t}\n\t\t\tcase arraybufferBinaryType:\n\t\t\t\tdata = rt.NewArrayBuffer(msg.data)\n\t\t\tdefault:\n\t\t\t\treturn fmt.Errorf(`unknown binaryType %q, the supported ones are \"blob\" and \"arraybuffer\"`, w.binaryType)\n\t\t\t}\n\t\t\tmust(rt, ev.DefineDataProperty(\"data\", rt.ToValue(data), sobek.FLAG_FALSE, sobek.FLAG_FALSE, sobek.FLAG_TRUE))\n\t\t} else {\n\t\t\tmust(\n\t\t\t\trt,\n\t\t\t\tev.DefineDataProperty(\"data\", rt.ToValue(string(msg.data)), sobek.FLAG_FALSE, sobek.FLAG_FALSE, sobek.FLAG_TRUE),\n\t\t\t)\n\t\t}\n\t\tmust(\n\t\t\trt,\n\t\t\tev.DefineDataProperty(\"origin\", rt.ToValue(w.url.String()), sobek.FLAG_FALSE, sobek.FLAG_FALSE, sobek.FLAG_TRUE),\n\t\t)\n","sourceCodeStart":485,"sourceCodeEnd":521,"githubUrl":"https://github.com/grafana/k6/blob/165bb3c1a492b7a4823907fe1e93a30645794737/internal/js/modules/k6/websockets/websockets.go#L485-L521","documentation":"Wrap of a Sobek runtime constructor failure while materializing an incoming binary WebSocket message: when binaryType is \"blob\", the raw bytes are passed to the script's Blob constructor (new Blob([data])). The wrapped error fires when that constructor call throws in the JS runtime — commonly because the Blob global is shadowed, its arguments are invalid, or the runtime environment lacks the expected built-in.","triggerScenarios":"Thrown at internal/js/modules/k6/websockets/websockets.go:478 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Avoid shadowing or replacing the global Blob constructor in the script scope","Switch ws.binaryType to \"arraybuffer\" to receive binary data without constructing a Blob","Update k6 to a version whose runtime reliably provides the Blob constructor"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"165bb3c1a492b7a4823907fe1e93a30645794737","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}