fix(browser): evict stale extension relay targets from cache#31362
Conversation
Greptile SummaryPrevents stale extension relay targets from persisting in Key changes:
Test coverage: Two new tests verify target removal on explicit destroy events and error-based pruning scenarios. The implementation correctly handles edge cases like multiple sessions per target and defensive error matching. Confidence Score: 5/5
Last reviewed commit: 7cc58a5 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dce97cbf23
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (cmd.sessionId) { | ||
| const removed = dropConnectedTargetSession(cmd.sessionId); | ||
| if (removed) { | ||
| broadcastDetachedTarget(removed); | ||
| return; |
There was a problem hiding this comment.
Avoid evicting reused sessions on late command errors
This eviction path assumes cmd.sessionId still identifies the stale target that produced the error, but this relay explicitly supports session ID reuse in Target.attachedToTarget (same session mapped to a new target). If an old in-flight command returns "No target with given id" after that remap, this block drops the current target for that session and broadcasts a synthetic detach, causing /json/list to lose a live tab and forcing unnecessary reattach failures. The prune logic needs to verify the failing command still matches the currently mapped target (for example via targetId correlation) before deleting by sessionId.
Useful? React with 👍 / 👎.
…w#31362) * fix(browser): prune stale extension relay targets * test(browser): cover relay stale target pruning * changelog: note extension relay stale target fix
…w#31362) * fix(browser): prune stale extension relay targets * test(browser): cover relay stale target pruning * changelog: note extension relay stale target fix
…w#31362) * fix(browser): prune stale extension relay targets * test(browser): cover relay stale target pruning * changelog: note extension relay stale target fix
…w#31362) * fix(browser): prune stale extension relay targets * test(browser): cover relay stale target pruning * changelog: note extension relay stale target fix
…w#31362) * fix(browser): prune stale extension relay targets * test(browser): cover relay stale target pruning * changelog: note extension relay stale target fix
…w#31362) * fix(browser): prune stale extension relay targets * test(browser): cover relay stale target pruning * changelog: note extension relay stale target fix
Summary
/json/listafter CDP sessions die, causing stale tab listings and follow-uptab not foundfailures.Target.targetDestroyed/Target.targetCrashed, and also prunes cached targets when forwarded CDP commands fail with missing-target/session errors.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
/json/listno longer keeps stale extension-tab cache entries after target-destroy/crash events.Security Impact (required)
No)No)No)No)No)Yes, explain risk + mitigation:Repro + Verification
Environment
profile=chrome)Steps
/json/list.Target.targetDestroyedand verify target is removed.Expected
Actual
Evidence
Human Verification (required)
What you personally verified (not just CI), and how:
pnpm vitest run src/browser/extension-relay.test.tsCompatibility / Migration
Yes)No)No)Failure Recovery (if this breaks)
src/browser/extension-relay.ts./json/list.Risks and Mitigations