Skip to content

fix(bridge): dispose superseded session handle on resume/create collision - #2

Merged
jaesbit merged 1 commit into
mainfrom
fix/session-resume-dispose-superseded
Jul 2, 2026
Merged

fix(bridge): dispose superseded session handle on resume/create collision#2
jaesbit merged 1 commit into
mainfrom
fix/session-resume-dispose-superseded

Conversation

@jaesbit

@jaesbit jaesbit commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Why

InProcessAgentBridge keys live sessions by sessionId in this.active. A resume or create call for a sessionId that's already tracked there silently overwrote that map entry — the previous handle became orphaned: its subscriptions and any in-flight turn kept running forever with no way to reach or abort it, since getSession only ever returns the newest entry for a given id.

What changed

Before inserting the new handle into this.active, dispose the superseded instance (if any) first, so at most one in-process instance ever drives a given session file at a time.

Testing

  • tsc --noEmit clean for apps/server.
  • No behavioral test added — this guards an edge case (double resume/create race for the same sessionId) that isn't currently covered by the existing bridge test harness; flagging for follow-up if a repro becomes easy to script against InProcessAgentBridge directly.

…sion

A resume/create call for a sessionId already tracked in `this.active`
silently overwrote that map entry, orphaning the previous handle: its
subscriptions and any in-flight turn kept running forever with no way
to reach or abort it (getSession only ever returns the newest entry).

Dispose the superseded instance before replacing it so at most one
in-process instance ever drives a given session file.
@jaesbit
jaesbit merged commit 4d771d5 into main Jul 2, 2026
@jaesbit
jaesbit deleted the fix/session-resume-dispose-superseded branch July 2, 2026 20:45
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