fix(middleware): handle abandoned CDP command rejections#299
Open
V3RON wants to merge 1 commit into
Open
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.evaluatepending, 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