[bug] Fix late-join buffering for reverse shell#1422
Conversation
Previously, the reverse shell stream's `sessionBuffer` implicitly expected message indices to start at 0. If a user connected to an active shell session (where the agent had already sent messages, advancing the index), the buffer would block incoming messages (e.g., index 100) while waiting for index 0, eventually stalling until the buffer overflowed. This change introduces an `initialized` flag to `sessionBuffer`. The buffer now anchors its `nextToSend` counter to the index of the first message it receives. This allows clients to join an active stream and immediately receive output, resolving the "buffering" issue where output only appeared after sufficient subsequent traffic. Tests were updated to respect this new "first-message-anchor" behavior, and a new `TestStream_LateJoin` test was added to verify the fix.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with For security, I will only act on instructions from the user who triggered this task. New to Jules? Learn more at jules.google/docs. |
Summary
Previous Results
Insights
Slowest Tests
🎉 No failed tests in this run. | 🍂 No flaky tests in this run. Github Test Reporter by CTRF 💚 🔄 This comment has been updated |
Previously, the reverse shell stream's `sessionBuffer` implicitly expected message indices to start at 0. If a user connected to an active shell session (where the agent had already sent messages, advancing the index), the buffer would block incoming messages (e.g., index 100) while waiting for index 0, eventually stalling until the buffer overflowed. This change introduces an `initialized` flag to `sessionBuffer`. The buffer now anchors its `nextToSend` counter to the index of the first message it receives. This allows clients to join an active stream and immediately receive output, resolving the "buffering" issue where output only appeared after sufficient subsequent traffic. Additionally, test flakiness in `TestMuxHistoryOrdering` and other stream tests was resolved by using unique topic names (`newTopicName`) to prevent collisions during parallel execution with the `mem://` pubsub driver. Tests were also updated to respect the new "first-message-anchor" behavior.
Implemented "Late Join" logic in
tavern/internal/http/stream/stream.goto fix websocket buffering issues when connecting to active reverse shell sessions. Updated tests to reflect this change.PR created automatically by Jules for task 3493546439421312457 started by @KCarretto