Skip to content

fix(middleware): handle abandoned CDP command rejections#299

Open
V3RON wants to merge 1 commit into
mainfrom
fix/agent-cdp-close-rejections
Open

fix(middleware): handle abandoned CDP command rejections#299
V3RON wants to merge 1 commit into
mainfrom
fix/agent-cdp-close-rejections

Conversation

@V3RON
Copy link
Copy Markdown
Contributor

@V3RON V3RON commented Jun 5, 2026

What is this?

This PR fixes a Rozenite for Agents crash where Metro could terminate after an agent session CDP socket closed while a command was still pending. The failure happened when socket teardown rejected an internally tracked command promise that no caller was still observing.

How does it work?

The session CDP command path now marks internally managed command promises as handled as soon as they are created, while still returning the same promise so awaited callers receive the original rejection. Domain messages also return a handled promise because they derive a new promise from the underlying CDP command. A regression test keeps a detached Runtime.evaluate pending, closes the websocket, and verifies that no process-level unhandled rejection is emitted.

Why is this useful?

Debugger disconnects, app reloads, and stopped agent sessions can now clean up pending CDP work without taking Metro down. This keeps Rozenite for Agents safer to use in shared Metro processes while preserving normal error behavior for callers that await command results.

Fixes #293

Mark session CDP command promises and domain-message promises as handled.

This prevents socket teardown from surfacing as an unhandled rejection when a caller
has detached from the command lifecycle.
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
rozenite Skipped Skipped Jun 5, 2026 11:03am

Request Review

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.

Rozenite for Agents: unhandled "CDP connection closed" in @rozenite/middleware crashes Metro on session socket drop

1 participant