You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
StdioTransport silently drops a final envelope that lacks a trailing newline #48
src/Transport/StdioTransport.php:72 loops over strpos($this->readBuffer, "\n") and only returns a decoded envelope when a newline is found in the buffer. When the upstream reader returns null to signal EOF at src/Transport/StdioTransport.php:89, the transport marks itself closed and either returns null immediately (if the buffer is empty) or continues the loop. On the next iteration there is still no newline, the closed branch fires, and the buffered partial line is discarded without ever being decoded. A peer that finishes its protocol exchange without a final \n therefore loses its last envelope — typically the terminal tool.result or session.close — even though the SDK accepts unterminated frames implicitly through CLI pipes.
The class docblock at src/Transport/StdioTransport.php:17 describes the framing as "Each envelope is encoded ... and appended with \n" but does not promise to require a terminator on read, and a strict-NDJSON implementation should still drain whatever remains in the buffer when EOF arrives.
Fix prompt: After the EOF path sets $this->closed = true, decode and return any non-empty residual content in $this->readBuffer exactly once before falling through to the return null close path. Add a unit test in tests/Unit/StdioTransportTest.php (creating it if necessary) that feeds a single encoded envelope without a trailing newline through StdioTransport::fromResources and asserts the envelope is returned before EOF.
Activity
fix: address 17 open issues across auth, isolation, idempotency, and …
nficano commentedon May 25, 2026
Fixed in #52 (commit 03afbaa).