ruvnet/ruflo · error

JSON parse error: ${error instanceof Error ? error.message :

Error message

JSON parse error: ${error instanceof Error ? error.message : String(error)}

What it means

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.

Source

Thrown at v3/mcp/transport/websocket.ts:452

      } catch {
        // Ignore send errors
      }
    }
  }

  /**
   * Parse incoming message with error handling
   */
  private parseMessage(data: RawData): any {
    try {
      if (this.config.enableBinaryMode && Buffer.isBuffer(data)) {
        // Could implement binary protocol here
        return JSON.parse(data.toString());
      }
      return JSON.parse(data.toString());
    } catch (error) {
      // Wrap JSON parse errors with more context
      throw new Error(`JSON parse error: ${error instanceof Error ? error.message : String(error)}`);
    }
  }

  /**
   * Serialize outgoing message
   */
  private serializeMessage(message: MCPResponse | MCPNotification): string | Buffer {
    if (this.config.enableBinaryMode) {
      // Could implement binary protocol here
      return JSON.stringify(message);
    }
    return JSON.stringify(message);
  }

  /**
   * Start heartbeat interval
   */
  private startHeartbeat(): void {

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. Validate that the peer sends well-formed JSON; log the raw payload for debugging.
  2. Handle protocol version mismatches between client and server.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at v3/mcp/transport/websocket.ts:452 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18). Data as JSON: /api/errors/2952fab3fadd8266. Report an issue: GitHub.