gravitational/teleport · error

sse event exceeded max size

Error message

sse event exceeded max size

What it means

Exported sentinel ErrEventTooLarge returned by the SSE reader iterator: an incoming server-sent event (event name, ID, or data line) would cause the accumulated event to exceed MaxReadEventSize (teleport.MaxHTTPResponseSize), which guards against unbounded memory consumption from a malicious or misbehaving server.

Source

Thrown at lib/httplib/sse/sse.go:35

package sse

import (
	"bufio"
	"bytes"
	"errors"
	"io"
	"iter"
	"strings"

	"github.com/gravitational/trace"

	"github.com/gravitational/teleport"
)

var (
	// ErrEventTooLarge is the error returned when SSE event is larger than
	// [MaxReadEventSize].
	ErrEventTooLarge = errors.New("sse event exceeded max size")
)

// MaxReadEventSize defines the max size that can be read from an [io.Reader]
// to complete the event.
const MaxReadEventSize = teleport.MaxHTTPResponseSize

// Event is a server-sent event.
type Event struct {
	Event string
	ID    string
	Data  []byte
	Retry string
}

// Empty reports whether the event is empty.
func (e Event) Empty() bool {
	return e.len() == 0
}

View on GitHub (pinned to 1283425b60)

Solutions

  1. Check whether the server legitimately sends events larger than MaxReadEventSize and reduce event payload size
  2. Verify the stream is not corrupted or malicious (e.g. a server sending an endless data line)
  3. If a larger limit is genuinely required, adjust the response size limit configuration and restart
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at lib/httplib/sse/sse.go:35 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of gravitational/teleport@1283425b60 (2026-09-02). Data as JSON: /api/errors/74993fc1be0b6636. Report an issue: GitHub.