Skip to content

fix(pty): serialize xterm screen writes - #837

Open
stevenahhh wants to merge 2 commits into
code-yeongyu:mainfrom
stevenahhh:fix/terminal-screen-write-flow-control
Open

fix(pty): serialize xterm screen writes#837
stevenahhh wants to merge 2 commits into
code-yeongyu:mainfrom
stevenahhh:fix/terminal-screen-write-flow-control

Conversation

@stevenahhh

@stevenahhh stevenahhh commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • serialize TerminalScreen writes through xterm parse callbacks
  • order resize recreation and replay with concurrent feeds
  • keep the queue usable after an individual write rejection

Root cause

TerminalRuntimeSession intentionally does not await screen.feed(), so fast PTY output could enqueue more than xterm's 50 MB pending-write watermark. xterm then rejected a feed with write data discarded, use flow control to avoid losing data; the discarded promise became an uncaught exception and exited Senpi.

Verification

  • regression test fails before the fix with the exact xterm error
  • npm test -- test/screen.test.ts: 45 passed, 7 skipped
  • npm run check: passed
  • 20,000 concurrent 4 KB feeds: 20,000 fulfilled, 0 rejected
  • .agents/skills/senpi-qa/scripts/pty-drive.mjs --self-test: 8/8 passed (pipe fallback on Windows)

Related xterm guidance: https://github.com/xtermjs/xtermjs.org/blob/f8670249e22dac222c428654d9fb39a957555f0b/_docs/guides/flowcontrol.md

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e61e59b596

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/pty/src/screen.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant