Skip to content

Send Target.detachedFromTarget event on detach#1929

Merged
krichprollsch merged 1 commit intolightpanda-io:mainfrom
mvanhorn:osc/1819-fix-detach-session-null
Mar 20, 2026
Merged

Send Target.detachedFromTarget event on detach#1929
krichprollsch merged 1 commit intolightpanda-io:mainfrom
mvanhorn:osc/1819-fix-detach-session-null

Conversation

@mvanhorn
Copy link
Contributor

Summary

  • detachFromTarget and setAutoAttach(autoAttach: false) both null bc.session_id without notifying the client. Per the CDP spec, detaching a session must fire a Target.detachedFromTarget event so the driver stops sending messages on the stale session ID.
  • Both code paths had TODO comments calling out this exact gap: // TODO should we send a Target.detachedFromTarget event?
  • This captures the session_id before nulling it and fires the event in both paths.

Changes

  • detachFromTarget: emit Target.detachedFromTarget with the session ID before nulling it
  • setAutoAttach(false): same treatment
  • New test: detachFromTarget emits the event after attach
  • New test: detachFromTarget without a session does not emit an event
  • New test: setAutoAttach(false) emits the event after attach

Test plan

  • All 368 existing tests pass (zig build test)
  • New tests cover event emission in both detach paths
  • Edge case: detach with no active session does not crash or emit

Fixes #1819

This contribution was developed with AI assistance (Claude Code + Codex).

detachFromTarget and setAutoAttach(false) both null bc.session_id
without notifying the client. Per the CDP spec, detaching a session
must fire a Target.detachedFromTarget event so the driver stops
sending messages on the stale session ID.

Capture the session_id before nulling it and fire the event in both
code paths. Add tests covering the event emission and the no-session
edge case.

Fixes lightpanda-io#1819

This contribution was developed with AI assistance (Claude Code + Codex).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@krichprollsch
Copy link
Member

Thanks for your contribution 🙏

@krichprollsch krichprollsch merged commit 9b02e49 into lightpanda-io:main Mar 20, 2026
17 of 19 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Mar 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Page unresponsive after Target.detachFromTarget — session_id set to null, no messages routed

2 participants