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
test(mcpgateway): wait for the background session close before the recovery check - #1623
TestHostEndsASessionItCannotRecheckForLong failed intermittently in CI with expected: 404, actual: 200 on its last request (for example on #1621, which does not touch internal/mcpgateway).
When the host ends a session it could not recheck, it unbinds it and closes the SDK session in the background (closeSessions). The test's next request finds no binding and no shared record, so it is passed to the SDK handler; if the background close has not finished yet, the SDK still knows the session and answers 200.
The test now waits for the hosted session to close before that request, as TestLongCallDoesNotReviveADeletedSession already does. Test-only change.
Delaying the background close by 30 ms reproduces the failure on every run; with the fix the whole package passes under the same delay.
Summary by CodeRabbit
Tests
Expanded coverage for long outages to verify that a hosted session is closed after its host reaches the unverified limit, rather than only being unbound. No user-facing behavior changes are included in this update.
No actionable comments were generated in the recent review.
Walkthrough
The long-outage test now captures the hosted server from the session binding and verifies that the hosted session eventually closes after the host reaches its unverified limit.
Changes: Hosted session closure
Layer / File(s)
Summary
Capture and verify hosted session closure internal/mcpgateway/sharedsessions_test.go
The test confirms that a session binding exists, saves its server, and waits for the hosted session to close after the host exceeds its unverified limit.
This is a test-only change that reduces flakiness in a session-closure test. It has no production impact, so merge risk is minimal.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the change: a test-only fix that waits for the background session close before the recovery check in mcpgateway. It matches the description and objectives, which describe the wait adde…
Description check
The description states the failure, its cause, and the fix. It names the affected test, the observed failure (expected 404, actual 200), the root cause (background closeSessions not finished before th…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the change: a test-only fix that waits for the background session close before the recovery check in mcpgateway. It matches the description and objectives, which describe the wait added before the final request in TestHostEndsASessionItCannotRecheckForLong. The title uses a conventional test(scope) prefix and is 81 characters, slightly over the usual 72-character guideline but still readable.
Full details: Description check
Explanation
The description states the failure, its cause, and the fix. It names the affected test, the observed failure (expected 404, actual 200), the root cause (background closeSessions not finished before the next request), the fix (wait for the hosted session to close, as TestLongCallDoesNotReviveADeletedSession does), and the verification (a 30 ms delay reproduces the failure, and the package passes with the fix). It follows the template's Description section. The template's optional AI Generated section is absent, which is acceptable because it is optional.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
A rabbit checks the session’s place, Then waits for closure, calm and keen. The host rejects the stale request, The server closes, as tests confirm. The rabbit hops through logs of green.
Recent review info
Automatic approval policy
Commit: 97b58f57ec0e.
Setting
Effective value
Source
Automatic approvals
Enabled
Global configuration
Merge risk
Moderate
Global configuration
Security risk
Low
Global configuration
Not set means no limit was configured after inheritance. Use @coderabbitai configuration to inspect the resolved settings and their sources.
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: ASSERTIVE
Plan: Advanced
Run ID: 7706c3a3-e873-4975-90a2-448f5bdc5316
Commits
Reviewing files that changed from the base of the PR and between 08a0111 and 97b58f5.
Files selected for processing: 1
internal/mcpgateway/sharedsessions_test.go
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 1 file
Auto-approved: Test-only change that fixes an intermittent flake by waiting for the background session close before performing the recovery check, without altering production behavior.
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
size:XS0-9 effective changed lines (test files excluded in mixed PRs).
2 participants
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.
Description
TestHostEndsASessionItCannotRecheckForLongfailed intermittently in CI withexpected: 404, actual: 200on its last request (for example on #1621, which does not touchinternal/mcpgateway).When the host ends a session it could not recheck, it unbinds it and closes the SDK session in the background (
closeSessions). The test's next request finds no binding and no shared record, so it is passed to the SDK handler; if the background close has not finished yet, the SDK still knows the session and answers 200.The test now waits for the hosted session to close before that request, as
TestLongCallDoesNotReviveADeletedSessionalready does. Test-only change.Delaying the background close by 30 ms reproduces the failure on every run; with the fix the whole package passes under the same delay.
Summary by CodeRabbit