yudai/gotty · error

failed to return Pong message to master

Error message

failed to return Pong message to master

What it means

Wrapped masterWrite failure in handleMasterReadEvent: the terminal received a Ping control message from the browser but writing the Pong reply back over the websocket failed, indicating the master connection is broken (closed, timed out, or write buffer saturated). The pong itself is lost, so the client's keepalive will fail.

Source

Thrown at webtty/webtty.go:181

	switch data[0] {
	case Input:
		if !wt.permitWrite {
			return nil
		}

		if len(data) <= 1 {
			return nil
		}

		_, err := wt.slave.Write(data[1:])
		if err != nil {
			return errors.Wrapf(err, "failed to write received data to slave")
		}

	case Ping:
		err := wt.masterWrite([]byte{Pong})
		if err != nil {
			return errors.Wrapf(err, "failed to return Pong message to master")
		}

	case ResizeTerminal:
		if wt.columns != 0 && wt.rows != 0 {
			break
		}

		if len(data) <= 1 {
			return errors.New("received malformed remote command for terminal resize: empty payload")
		}

		var args argResizeTerminal
		err := json.Unmarshal(data[1:], &args)
		if err != nil {
			return errors.Wrapf(err, "received malformed data for terminal resize")
		}
		rows := wt.rows
		if rows == 0 {

View on GitHub (pinned to a080c85cbc)

Solutions

  1. Treat this as a dead master: tear down the session and release the slave
  2. Add write deadlines to masterWrite so saturated sockets fail fast instead of hanging
  3. Client-side: implement reconnect (webtty WithReconnect) to survive transient drops
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at webtty/webtty.go:181 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of yudai/gotty@a080c85cbc (2026-09-02). Data as JSON: /api/errors/d480677ad7853216. Report an issue: GitHub.