wavetermdev/waveterm · error

input data too large

Error message

input data too large

What it means

EncodeWaveOSCBytes enforces a hard 64 MB ceiling on the payload it will wrap in an OSC sequence, because terminals cannot reliably handle arbitrarily large escape sequences. Inputs larger than 64*1024*1024 bytes are rejected without attempting to encode.

Source

Thrown at pkg/wshutil/wshutil.go:80

}

func oscPrefixLen(oscNum string) int {
	return 3 + len(oscNum)
}

func makeOscPrefix(oscNum string) []byte {
	output := make([]byte, oscPrefixLen(oscNum))
	copyOscPrefix(output, oscNum)
	return output
}

func EncodeWaveOSCBytes(oscNum string, barr []byte) ([]byte, error) {
	if len(oscNum) != 5 {
		return nil, fmt.Errorf("oscNum must be 5 characters")
	}
	const maxSize = 64 * 1024 * 1024 // 64 MB
	if len(barr) > maxSize {
		return nil, fmt.Errorf("input data too large")
	}
	hasControlChars := false
	for _, b := range barr {
		if b < 0x20 || b == 0x7F {
			hasControlChars = true
			break
		}
	}
	if !hasControlChars {
		// If no control characters, directly construct the output
		// \x1b] (2) + WaveOSC + ; (1) + message + \x07 (1)
		output := make([]byte, oscPrefixLen(oscNum)+len(barr)+1)
		copyOscPrefix(output, oscNum)
		copy(output[oscPrefixLen(oscNum):], barr)
		output[len(output)-1] = BEL
		return output, nil
	}

View on GitHub (pinned to a4447c1563)

Solutions

  1. Split the payload into chunks below 64 MB and send each separately.
  2. Move bulk data through a file or separate data channel instead of the OSC stream.
  3. Cap payload size at the producer before pushing to the channel.
  4. Compress the data before sending if the receiving side supports it.

Example fix

// before
barr, err := EncodeWaveOSCBytes("1337;", hugeBlob)
// after
const chunkMax = 32 * 1024 * 1024
for i := 0; i < len(hugeBlob); i += chunkMax {
    end := min(i+chunkMax, len(hugeBlob))
    barr, err := EncodeWaveOSCBytes("1337;", hugeBlob[i:end])
    if err != nil { return err }
    if _, err := output.Write(barr); err != nil { return err }
}
Defensive patterns

Strategy: validation

Validate before calling

const oscMaxSize = 64 * 1024 * 1024
if len(barr) > oscMaxSize {
    return fmt.Errorf("payload %d bytes exceeds %d limit", len(barr), oscMaxSize)
}

Try / catch

barr, err := EncodeWaveOSCBytes(oscNum, data)
if err != nil {
    if strings.Contains(err.Error(), "input data too large") {
        return chunkAndSend(data) // fallback path
    }
    return err
}

Prevention

When it happens

Trigger: Calling EncodeWaveOSCBytes (directly or via AdaptMsgChToPty / EncodeWaveOSCMessageEx) with a []byte or JSON-marshalled RpcMessage whose length exceeds 64 MB.

Common situations: Sending a very large file's contents through the terminal OSC channel; an RpcMessage containing a huge base64 blob or oversized command output.

Understand the failure class

Background: payload too large / request exceeds maximum size: why libraries cap bytes and how to fix oversize payloads — this error's family across 50 libraries.

Related errors


AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01). Data as JSON: /api/errors/b2b3a86808aeeb84. Report an issue: GitHub.