Skip to content

devtools: Add support for one-way protocol messages#43230

Merged
eerii merged 1 commit into
servo:mainfrom
brentschroeter:devtools-one-way-messages
Mar 13, 2026
Merged

devtools: Add support for one-way protocol messages#43230
eerii merged 1 commit into
servo:mainfrom
brentschroeter:devtools-one-way-messages

Conversation

@brentschroeter

Copy link
Copy Markdown
Contributor

Some Remote Debugging Protocol message types are specified as oneway, meaning that they expect no reply. Sending anything—including an error—in response to these messages throws the devtools client and actor out of sync.

As noted in the ClientRequest docstring, most client messages expect exactly one reply, so ClientRequest::handle() includes a fail-safe that automatically sends an error message if none of the reply(), reply_unchecked(), or reply_final() methods have been called.

This change introduces an additional method, ClientRequest::mark_handled(), which allows the actor handling the request to disarm the fail-safe without sending a reply over the wire, and it adds handling logic for 3 one-way message types that are frequently emitted by the Firefox Toolbox.

Testing: This change introduces no new tests. Unless we take the unusual step of enumerating all supported one-way message types and validating each, automated tests provide little assurance of correctness. Meaningfully testing this feature would be cumbersome, and it would likely hamper future development more than it would help.

Signed-off-by: Brent Schroeter <contact@brentsch.com>
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Mar 13, 2026
@brentschroeter

Copy link
Copy Markdown
Contributor Author

Example of a one-way message type in the Firefox spec, for reference: https://github.com/mozilla-firefox/firefox/blob/a86d8293217bbdc69abd541c9c7f8a4c6e227a8c/devtools/shared/specs/watcher.js#L28

@brentschroeter

Copy link
Copy Markdown
Contributor Author

@eerii Another small stepping stone on the way to fixing navigation for the devtools inspector panel.

@eerii eerii left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! This gets rid of some of the warnings when closing DevTools.


/// Like `reply`, but it doesn't check if it is a valid reply.
/// Sometimes the client breaks the rules and expects an out of form message.
pub fn reply_unchecked<T: Serialize>(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make a followup to remove reply_unchecked, as it no longer needs to be separate from reply. We can use write_json_packet followed by mark_handled. As far as I can tell this is only used in frame::getEnvironment.

@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Mar 13, 2026
@eerii eerii added this pull request to the merge queue Mar 13, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Mar 13, 2026
Merged via the queue into servo:main with commit 69a1f99 Mar 13, 2026
33 checks passed
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Mar 13, 2026
github-merge-queue Bot pushed a commit that referenced this pull request Mar 13, 2026
`reply_unchecked` was added in #42007 since `getEnvironment` from the
frame actor has a `type` field but it already counts as a final reply,
unlike every other message like it. Since it is only used there, we can
revert the `reply_unchecked` change and use the new `mark_handled`
instead.

Depends on: #43230
Testing: DevTools tests

Signed-off-by: eri <eri@igalia.com>
offline-ant pushed a commit to offline-ant/havi that referenced this pull request Jun 4, 2026
Some Remote Debugging Protocol message types are specified as `oneway`,
meaning that they expect no reply. Sending anything—including an
error—in response to these messages throws the devtools client and actor
out of sync.

As noted in the `ClientRequest` docstring, most client messages expect
exactly one reply, so `ClientRequest::handle()` includes a fail-safe
that automatically sends an error message if none of the `reply()`,
`reply_unchecked()`, or `reply_final()` methods have been called.

This change introduces an additional method,
`ClientRequest::mark_handled()`, which allows the actor handling the
request to disarm the fail-safe without sending a reply over the wire,
and it adds handling logic for 3 one-way message types that are
frequently emitted by the Firefox Toolbox.

Testing: This change introduces no new tests. Unless we take the unusual
step of enumerating all supported one-way message types and validating
each, automated tests provide little assurance of correctness.
Meaningfully testing this feature would be cumbersome, and it would
likely hamper future development more than it would help.

Signed-off-by: Brent Schroeter <contact@brentsch.com>
(cherry picked from commit 69a1f99)
offline-ant pushed a commit to offline-ant/havi that referenced this pull request Jun 4, 2026
…#43236)

`reply_unchecked` was added in servo#42007 since `getEnvironment` from the
frame actor has a `type` field but it already counts as a final reply,
unlike every other message like it. Since it is only used there, we can
revert the `reply_unchecked` change and use the new `mark_handled`
instead.

Depends on: servo#43230
Testing: DevTools tests

Signed-off-by: eri <eri@igalia.com>
(cherry picked from commit 5c30339)
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.

3 participants