{"record":{"id":"0534a1f226e5e60a","repo":"grafana/k6","slug":"got-error-while-trying-to-export-arraybufferview-t","errorCode":null,"errorMessage":"got error while trying to export ArrayBufferView to bytes: %w","messagePattern":"got error while trying to export ArrayBufferView to bytes: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/websockets/websockets.go","lineNumber":691,"sourceCode":"\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))\n\t\t}\n\n\t\tvar b []byte\n\t\terr = rt.ExportTo(msg, &b)\n\t\tif err != nil {\n\t\t\tcommon.Throw(rt,\n\t\t\t\tfmt.Errorf(\"got error while trying to export ArrayBufferView to bytes: %w\", err))\n\t\t}\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\t}\n}\n\nfunc (w *webSocket) sendArrayBuffer(o sobek.ArrayBuffer) {\n\tb := o.Bytes()\n\tw.bufferedAmount += len(b)\n\tw.writeQueueCh <- message{\n\t\tmtype: websocket.BinaryMessage,\n\t\tdata:  b,\n\t\tt:     time.Now(),\n\t}","sourceCodeStart":673,"sourceCodeEnd":709,"githubUrl":"https://github.com/grafana/k6/blob/165bb3c1a492b7a4823907fe1e93a30645794737/internal/js/modules/k6/websockets/websockets.go#L673-L709","documentation":"Wrap of a Sobek export failure in send(): the argument passed the ArrayBuffer.isView check, but converting the typed-array view (Uint8Array, DataView, etc.) into Go []byte via rt.ExportTo failed. This indicates the value's internal structure is not a valid view over an ArrayBuffer at export time — usually the buffer was detached or a non-standard object tricked the isView check.","triggerScenarios":"Thrown at internal/js/modules/k6/websockets/websockets.go:666 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Send a copy of the data instead of a view over a detached/transferred buffer","Construct a fresh Uint8Array from the data before sending","Fall back to sending a string or Blob if the view keeps failing to export"],"exampleFix":null,"handlingStrategy":"try-catch","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"}