{"record":{"id":"6fe10af870762d35","repo":"grafana/k6","slug":"syntaxerror-failed-to-execute-close-on-websock","errorCode":null,"errorMessage":"SyntaxError: Failed to execute 'close' on 'WebSocket': The message must not be greater than 123 bytes","messagePattern":"SyntaxError: Failed to execute 'close' on 'WebSocket': The message must not be greater than 123 bytes","errorType":"exception","errorClass":"SyntaxError","httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/websockets/websockets.go","lineNumber":781,"sourceCode":"func isValidCloseReason(reason string) bool {\n\treturn len([]byte(reason)) <= 123\n}\n\nfunc (w *webSocket) close(code int, reason string) error {\n\tif w.readyState == CLOSED || w.readyState == CLOSING {\n\t\treturn nil\n\t}\n\n\tif code != 0 && !isValidClientCloseCode(code) {\n\t\treturn fmt.Errorf(\n\t\t\t\"InvalidAccessError: Failed to execute 'close' on 'WebSocket': \"+\n\t\t\t\t\"The close code must be either 1000, or between 3000 and 4999. %d is neither\",\n\t\t\tcode,\n\t\t)\n\t}\n\n\tif !isValidCloseReason(reason) {\n\t\treturn errors.New(\n\t\t\t`SyntaxError: Failed to execute 'close' on 'WebSocket': The message must not be greater than 123 bytes`,\n\t\t)\n\t}\n\n\tif code == 0 {\n\t\tcode = websocket.CloseNormalClosure\n\t}\n\n\tw.readyState = CLOSING\n\tw.closeCode = code\n\n\tw.writeQueueCh <- message{\n\t\tmtype: websocket.CloseMessage,\n\t\tdata:  websocket.FormatCloseMessage(code, reason),\n\t\tt:     time.Now(),\n\t}\n\n\treturn nil","sourceCodeStart":763,"sourceCodeEnd":799,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/websockets/websockets.go#L763-L799","documentation":"Error \"SyntaxError: Failed to execute 'close' on 'WebSocket': The message must not be greater than 123 bytes\" thrown in grafana/k6.","triggerScenarios":"Thrown at internal/js/modules/k6/websockets/websockets.go:781 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}