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
fix: Target.attachToTarget returns unique session id per call
Target.attachToTarget was reusing the existing bc.session_id when one
was already set (via the `orelse` pattern). The CDP spec requires a
fresh unique sessionId per attachToTarget call, as a single target can
have multiple sessions attached simultaneously.
This broke Playwright's ctx.newCDPSession(page) flow: the returned
sessionId was the same as the page's existing session, so Playwright's
createChildSession() overwrote _sessions[sid] with a new empty object,
orphaning the page session's pending callbacks and triggering
assert(!object.id).
Changes:
- doAttachtoTarget: always call session_id_gen.next(). First attach
sets bc.session_id (primary), subsequent attach sets bc.alt_session_id.
- Copy session IDs into fixed buffers (session_id_buf / alt_session_id_buf)
because session_id_gen.next() reuses its internal buffer and previous
slices would be invalidated.
- attachToBrowserTarget: also copy into session_id_buf for safety.
- isValidSessionId: accept both primary and alt session IDs.
- callInspector / onInspectorResponse: route V8 inspector replies back
to the requesting session via inspector_reply_session.
- runtime.zig sendInspector: pass cmd.input.session_id to callInspector.
- Add test: "attachToTarget returns unique sessionId per call" verifying
two successive attach calls produce different session IDs.
Amp-Thread-ID: https://ampcode.com/threads/T-019d5277-a92a-736b-bcb4-8aa78109c21d
Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d5277-a92a-736b-bcb4-8aa78109c21d
Co-authored-by: Amp <amp@ampcode.com>
0 commit comments