wavetermdev/waveterm · error
error encoding osc message (AdaptMsgChToPty): %w
Error message
error encoding osc message (AdaptMsgChToPty): %w
What it means
AdaptMsgChToPty wraps each channel message in a Wave OSC escape sequence via EncodeWaveOSCBytes before writing to the pty. This error means the OSC encoding step failed for a message, before any bytes were written.
Source
Thrown at pkg/wshutil/wshrpcio.go:53
return fmt.Errorf("error writing to output (AdaptOutputChToStream): %w", err)
}
// write trailing newline
if _, err := output.Write([]byte{'\n'}); err != nil {
drain = true
return fmt.Errorf("error writing trailing newline to output (AdaptOutputChToStream): %w", err)
}
}
return nil
}
func AdaptMsgChToPty(outputCh chan []byte, oscEsc string, output io.Writer) error {
if len(oscEsc) != 5 {
panic("oscEsc must be 5 characters")
}
for msg := range outputCh {
barr, err := EncodeWaveOSCBytes(oscEsc, msg)
if err != nil {
return fmt.Errorf("error encoding osc message (AdaptMsgChToPty): %w", err)
}
if _, err := output.Write(barr); err != nil {
return fmt.Errorf("error writing osc message (AdaptMsgChToPty): %w", err)
}
}
return nil
}
View on GitHub (pinned to a4447c1563)
Solutions
- Reduce the message size before sending it through outputCh.
- Chunk large payloads into multiple smaller messages.
- Avoid routing bulk data (file reads, large command output) through the OSC message channel.
- Check message origin upstream and cap payload size there.
Example fix
// before
outputCh <- largePayload // may exceed 64MB
// after
for _, chunk := range chunkBytes(largePayload, 1<<20) {
outputCh <- chunk
} Defensive patterns
Strategy: validation
Validate before calling
if len(msg) > 64*1024*1024 {
return errors.New("message exceeds OSC encoding limit")
} Try / catch
if err := AdaptMsgChToPty(ch, oscEsc, pty); err != nil {
if strings.Contains(err.Error(), "input data too large") {
return handleOversizedPayload()
}
return err
} Prevention
- Cap message sizes at the producer before pushing to the channel
- Chunk large payloads into multiple messages
- Keep bulk data transfers off the OSC message channel
When it happens
Trigger: EncodeWaveOSCBytes(oscEsc, msg) returns an error for a message coming off outputCh — practically, when the message exceeds the 64 MB maxSize limit (the oscEsc length is validated by panic at function entry, so encoding failures are effectively size failures).
Common situations: A huge RPC payload (e.g. a large file read result) is routed to terminal output and exceeds the 64 MB OSC limit.
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
- input data too large
- failed to decode base64 data: %w
- oscNum must be 5 characters
- beginning of file
- procinfo: process not found
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/6ea347b83a103a36.
Report an issue: GitHub.