{"record":{"id":"38dd78617c69686c","repo":"grafana/k6","slug":"unsupported-send-type-t","errorCode":null,"errorMessage":"unsupported send type %T","messagePattern":"unsupported send type %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/websockets/websockets.go","lineNumber":666,"sourceCode":"\tw.assertStateOpen()\n\n\tswitch o := msg.Export().(type) {\n\tcase string:\n\t\tw.bufferedAmount += len(o)\n\t\tw.writeQueueCh <- message{\n\t\t\tmtype: websocket.TextMessage,\n\t\t\tdata:  []byte(o),\n\t\t\tt:     time.Now(),\n\t\t}\n\tcase *sobek.ArrayBuffer:\n\t\tw.sendArrayBuffer(*o)\n\tcase sobek.ArrayBuffer:\n\t\tw.sendArrayBuffer(o)\n\tcase map[string]any:\n\t\trt := w.vu.Runtime()\n\t\tobj := msg.ToObject(rt)\n\t\tif !isBlob(obj, w.blobConstructor) {\n\t\t\tcommon.Throw(rt, fmt.Errorf(\"unsupported send type %T\", o))\n\t\t}\n\n\t\tb := extractBytes(obj, rt)\n\t\tw.bufferedAmount += len(b)\n\t\tw.writeQueueCh <- message{\n\t\t\tmtype: websocket.BinaryMessage,\n\t\t\tdata:  b,\n\t\t\tt:     time.Now(),\n\t\t}\n\tdefault:\n\t\trt := w.vu.Runtime()\n\t\tisView, err := isArrayBufferView(rt, msg)\n\t\tif err != nil {\n\t\t\tcommon.Throw(rt,\n\t\t\t\tfmt.Errorf(\"got error while trying to check if argument is ArrayBufferView: %w\", err))\n\t\t}\n\t\tif !isView {\n\t\t\tcommon.Throw(rt, fmt.Errorf(\"unsupported send type %T\", o))","sourceCodeStart":648,"sourceCodeEnd":684,"githubUrl":"https://github.com/grafana/k6/blob/165bb3c1a492b7a4823907fe1e93a30645794737/internal/js/modules/k6/websockets/websockets.go#L648-L684","documentation":"Type guard in the WebSocket send path: the argument exported to Go as a map[string]any (a plain JS object) was checked against the Blob constructor and is not a Blob. send() only accepts string, ArrayBuffer, ArrayBuffer views, and Blob instances, so any other object type (plain object, class instance, number, boolean) reaching this branch is rejected, mirroring the browser's TypeError for unsupported send data.","triggerScenarios":"Thrown at internal/js/modules/k6/websockets/websockets.go:641 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Convert the data before sending: JSON.stringify(obj) for text frames","Wrap binary data in a Blob or ArrayBuffer/TypedArray for binary frames","Pass primitive strings directly: ws.send('hello')"],"exampleFix":null,"handlingStrategy":"type-guard","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-14T00:17:10.932Z"}