Skip to content

fix(agent/reconnectingpty): read reconnecting-PTY init with io.ReadFull#26538

Open
yuriy-at-persona wants to merge 1 commit into
coder:mainfrom
yuriy-at-persona:fix/reconnectingpty-init-readfull
Open

fix(agent/reconnectingpty): read reconnecting-PTY init with io.ReadFull#26538
yuriy-at-persona wants to merge 1 commit into
coder:mainfrom
yuriy-at-persona:fix/reconnectingpty-init-readfull

Conversation

@yuriy-at-persona

Copy link
Copy Markdown

handleConn reads the length-prefixed AgentReconnectingPTYInit with a single conn.Read for the 2-byte length and another for the body. A single Read on a network connection can return fewer bytes than requested, so when the init spans multiple segments (more likely with a larger Command) the body is read short and left NUL-padded, json.Unmarshal fails with failed to unmarshal init, and the agent returns without starting the reconnecting PTY. The session then connects but delivers no output, intermittently.

Read both the length prefix and the body with io.ReadFull, matching the length-prefixed framing read in agent/boundarylogproxy/codec.

Note: the length prefix is a uint16, so an init larger than 64 KiB would still wrap; that is a separate pre-existing issue and is not addressed here.

handleConn read the length-prefixed AgentReconnectingPTYInit with single
conn.Read calls. A single Read on a network connection can return fewer
bytes than requested, so when the init spans multiple segments the body is
read short and left NUL-padded, json.Unmarshal fails with "failed to
unmarshal init", and the agent returns without starting the PTY. The
session then connects but delivers no output, intermittently.

Read both the length prefix and the body with io.ReadFull, matching the
length-prefixed framing read in agent/boundarylogproxy/codec.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the community Pull Requests and issues created by the community. label Jun 19, 2026
@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@datadog-coder

datadog-coder Bot commented Jun 19, 2026

Copy link
Copy Markdown

Pipelines

⚠️ Warnings

🚦 1 Pipeline job failed

contrib | cla   View in Datadog   GitHub Actions

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: b0012be | Docs | Give us feedback!

@yuriy-at-persona

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

cdrci2 added a commit to coder/cla that referenced this pull request Jun 19, 2026
@yuriy-at-persona yuriy-at-persona marked this pull request as ready for review June 19, 2026 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community Pull Requests and issues created by the community.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant