{"record":{"id":"2952fab3fadd8266","repo":"ruvnet/ruflo","slug":"json-parse-error-error-instanceof-error-error","errorCode":null,"errorMessage":"JSON parse error: ${error instanceof Error ? error.message : String(error)}","messagePattern":"JSON parse error: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/mcp/transport/websocket.ts","lineNumber":452,"sourceCode":"      } catch {\n        // Ignore send errors\n      }\n    }\n  }\n\n  /**\n   * Parse incoming message with error handling\n   */\n  private parseMessage(data: RawData): any {\n    try {\n      if (this.config.enableBinaryMode && Buffer.isBuffer(data)) {\n        // Could implement binary protocol here\n        return JSON.parse(data.toString());\n      }\n      return JSON.parse(data.toString());\n    } catch (error) {\n      // Wrap JSON parse errors with more context\n      throw new Error(`JSON parse error: ${error instanceof Error ? error.message : String(error)}`);\n    }\n  }\n\n  /**\n   * Serialize outgoing message\n   */\n  private serializeMessage(message: MCPResponse | MCPNotification): string | Buffer {\n    if (this.config.enableBinaryMode) {\n      // Could implement binary protocol here\n      return JSON.stringify(message);\n    }\n    return JSON.stringify(message);\n  }\n\n  /**\n   * Start heartbeat interval\n   */\n  private startHeartbeat(): void {","sourceCodeStart":434,"sourceCodeEnd":470,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/mcp/transport/websocket.ts#L434-L470","documentation":"WebSocketTransport.parseMessage's JSON.parse of the incoming frame threw; the raw data was not valid JSON (corrupt, truncated, or non-JSON protocol noise). The parse error is wrapped with the underlying message so the receiving side can log and drop the malformed frame.","triggerScenarios":"Thrown at v3/mcp/transport/websocket.ts:452 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Validate that the peer sends well-formed JSON; log the raw payload for debugging.","Handle protocol version mismatches between client and server."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}