Settle artifacts before sending terminal#30
Closed
jackcbrown89 wants to merge 2 commits intomainfrom
Closed
Conversation
The prior fix drained before closing the socket, but the server closes the WS immediately after sending end_session_message — so any artifact upload request fired between terminal and end_session_message still never gets its response back. Chokidar's awaitWriteFinish delays `add` events ~2s, so artifacts written by post-agent commands are always discovered *after* we respond. Move the drain (sleep + waitForPendingRequests) to run before the terminal is sent, so uploads complete while the server is still waiting on our reply.
Contributor
Author
|
Superseded by end_session_confirm_message protocol change |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PR #29 moved the drain to run before
ws.close()on orderly session end. But the log below shows the drain still happens after the WS is closed:The server closes the WS immediately after sending
end_session_message, so anything we try to send between the terminal and close (including late chokidar-triggeredartifact_upload_request_messages) is silently dropped bysend()'sreadyState === OPENguard.Chokidar's
awaitWriteFinishdelaysaddevents by ~2s, so artifacts written by post-agent commands are always discovered after the terminal has already been sent.Fix: move the drain (sleep +
waitForPendingRequests) to run beforesend(terminal). Now artifacts get uploaded while the server is still waiting on our reply, instead of trying to send on an already-dead socket.Bumps version to 0.11.2.
Test plan
npx vitest run src/session.test.ts— all 29 tests passNote
Medium Risk
Changes request completion timing and artifact upload ordering in the WebSocket session, which could impact latency and introduce new waiting/hanging behavior if artifact uploads don’t complete as expected.
Overview
Ensures artifacts produced during an invocation are settled and their queued upload round-trips complete before
send(terminal)inWebSocketSession.handleRequest, avoiding artifact upload requests/responses being lost when the server closes the socket immediately after the terminal.Bumps
runtimeuseversion from0.11.1to0.11.2(includingpackage-lock.json).Reviewed by Cursor Bugbot for commit 97ce6ec. Bugbot is set up for automated code reviews on this repo. Configure here.