Skip to content

[bug] Fix late-join buffering for reverse shell#1422

Merged
KCarretto merged 3 commits intomainfrom
fix-reverse-shell-buffering-3493546439421312457
Dec 27, 2025
Merged

[bug] Fix late-join buffering for reverse shell#1422
KCarretto merged 3 commits intomainfrom
fix-reverse-shell-buffering-3493546439421312457

Conversation

@google-labs-jules
Copy link
Copy Markdown
Contributor

Implemented "Late Join" logic in tavern/internal/http/stream/stream.go to 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

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.
@google-labs-jules
Copy link
Copy Markdown
Contributor Author

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!


For security, I will only act on instructions from the user who triggered this task.

New to Jules? Learn more at jules.google/docs.

@KCarretto KCarretto changed the title Fix reverse shell websocket buffering (Late Join) [bug] Fix late-join buffering for reverse shell Dec 27, 2025
@KCarretto KCarretto marked this pull request as ready for review December 27, 2025 03:16
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 27, 2025

Summary

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Other ❓ Flaky 🍂 Duration ⏱️
10134    ±0 10134    ±0 0    ±0 0    ±0 0    ±0 0    ±0 1ms    ±0

Previous Results

Build 🏗️ Result 🧪 Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Other ❓ Flaky 🍂 Duration ⏱️
#20 10134 10134 0 0 0 0 26.9s

Insights

Average Tests per Run Total Flaky Tests Total Failed Slowest Test (p95)
10134 0 0 44.8s

Slowest Tests

Test 📝 Results 📊 Duration (avg) ⏱️ Duration (p95) ⏱️
eldritch: random::string_impl::tests::test_string_uniform 12 39.0s 44.8s
eldritch: random::string_impl::tests::test_string_uniform 12 39.0s 44.8s
eldritch: random::string_impl::tests::test_string_uniform 12 39.0s 44.8s
eldritch: random::string_impl::tests::test_string_uniform 12 39.0s 44.8s
eldritch: random::string_impl::tests::test_string_uniform 12 39.0s 44.8s
eldritch: random::string_impl::tests::test_string_uniform 12 39.0s 44.8s
eldritch: random::string_impl::tests::test_string_uniform 12 39.0s 44.8s
eldritch: random::string_impl::tests::test_string_uniform 12 39.0s 44.8s
eldritch: random::string_impl::tests::test_string_uniform 12 39.0s 44.8s
eldritch: random::string_impl::tests::test_string_uniform 12 39.0s 44.8s

🎉 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.
@KCarretto KCarretto requested review from Cictrone and hulto December 27, 2025 03:44
@KCarretto KCarretto merged commit 8ef8ea8 into main Dec 27, 2025
6 checks passed
@KCarretto KCarretto deleted the fix-reverse-shell-buffering-3493546439421312457 branch December 27, 2025 04:00
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