{"record":{"id":"6667a6f6a5184c78","repo":"grafana/k6","slug":"got-error-while-trying-to-check-if-argument-is-arr","errorCode":null,"errorMessage":"got error while trying to check if argument is ArrayBufferView: %w","messagePattern":"got error while trying to check if argument is ArrayBufferView: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/websockets/websockets.go","lineNumber":681,"sourceCode":"\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))\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}","sourceCodeStart":663,"sourceCodeEnd":699,"githubUrl":"https://github.com/grafana/k6/blob/165bb3c1a492b7a4823907fe1e93a30645794737/internal/js/modules/k6/websockets/websockets.go#L663-L699","documentation":"Wrap of a Sobek runtime failure in send()'s default branch: before deciding whether the argument is an ArrayBufferView, k6 invokes the script's ArrayBuffer.isView function inside rt.Try. The wrapped error means that lookup/call itself threw — the ArrayBuffer global or its isView method was replaced or shadowed by script code — not that the argument type is wrong.","triggerScenarios":"Thrown at internal/js/modules/k6/websockets/websockets.go:656 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Do not override, delete, or shadow the global ArrayBuffer object in the script","Check for script-side polyfills or mocks that replace built-in constructors","Send data as a plain string or Blob to bypass the ArrayBufferView check"],"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"}