Repository navigation
fix(realtime): end impersonated connections when the impersonator flag is removed - #14041
Conversation
…g is removed The HTTP API re-checks the impersonator flag on every request, but an impersonated socket kept the target's roles until the impersonator's session ended. users.*.update.impersonator now closes the connections that user opened while impersonating. The impersonator's events also refresh the expiry of those connections, so extending the impersonator's session extends them instead of closing them at the expiry they were opened with. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
🟢 Tier S · Ready to merge
The pull request closes impersonated realtime connections when the actor loses the impersonator flag and refreshes connection expiry when the actor's session is extended. E2E coverage now checks both flag removal and delivery of target events after the original session expiry. Latest changes: The newest commit adds an isolated-project E2E test that extends the actor's session, polls until an unextended reference session expires, and verifies the impersonated socket still receives target events and responds to ping.
📂 Walkthrough · 2
✅ Fixed since the last review · 1
Reviewed the commits since |
…once extended Runs on its own project with the 60s minimum session duration, extends the impersonator's session, waits until an unextended session from the same moment is refused, then checks the impersonated socket still gets the target's events. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
a1eb2d7
into
fix/realtime-session-expiry
Stacked on #14039 (→ #14038 → #14040 → #14024 → #14021).
Why
Two gaps in how impersonated connections follow the impersonator, from #14024 combined with #14039:
impersonatoron every request (app/init/resources/request.php), so turning it off stops impersonation immediately. An impersonated realtime socket only closed when the impersonator was deleted/blocked or their session ended, so it kept the target's roles after the flag was removed.What
In the impersonating loop (connections a user opened while impersonating, re-checked on that user's
users.*events):users.*.update.impersonatorisn't on the fix(realtime): skip re-resolving connections on user events that change no access #14038 skip list, so it reaches this loop.expirefrom the impersonator's session (User::getSessionExpiry()), so asessions.*.updateon it carries over.Tests
E2E:
testConnectionEndsWithImpersonatorSessiongains a step that turns the actor'simpersonatorflag off and asserts a 401 and close, then turns it back on for the following "actor is blocked" step. Not run locally (no Docker); relying on CI. Lint, PHPStan and Rector pass.testImpersonatedConnectionFollowsSessionExtensioncovers the session extension: on its own project with the 60s minimum duration, it extends the actor's session, polls until an unextended session created at the same time is refused, then checks the impersonated socket still receives the target's events. It takes about a minute because of that minimum.🤖 Generated with Claude Code