Skip to content

docs: clarify debugger.sendCommand timing and empty-result behavior - #53114

Merged
MarshallOfSound merged 3 commits into
electron:mainfrom
JACOBIAN01:docs/debugger-sendcommand-behavior
Sep 5, 2026
Merged

MarshallOfSound merged 3 commits into
electron:mainfrom
JACOBIAN01:docs/debugger-sendcommand-behavior

Conversation

@JACOBIAN01

Copy link
Copy Markdown
Contributor

Description of Change

This documents two behaviors of debugger.sendCommand() reported years
ago (#14810, #14811) but only ever tracked as a documentation gap
(#14822) - never reflected in docs/api/debugger.md. Both underlying
reports were closed as working-as-intended; the behavior itself hasn't
changed, it was just never written down. I re-verified both against
current Electron (Promise-based API, not the callback API from 2018)
before writing this.

Evidence

1. Delay before navigation - sendCommand('Page.enable') called
immediately after attach(), before loadFile():

Log 1 1787383009851
Log 3 1787383010245  // loadFile() called ~394ms later
Log 2 1787383010690  // sendCommand resolved ~445ms after loadFile was called

Control run - same command sent after the page had already loaded once:

Log 2 1787383542866  // page finished loading
Log 3 1787383542885  // sendCommand resolved ~19ms later

~445ms vs ~19ms: pending navigation measurably delays resolution.

2. Empty object on success:

Network.enable resolved with: {}
Page.getNavigationHistory resolved with: {"currentIndex":0,"entries":[...]}
Not.ARealMethod rejected with: 'Not.ARealMethod' wasn't found

Matches DispatchProtocolMessage in
shell/browser/api/electron_api_debugger.cc:81, which resolves with an
empty DictValue when the protocol response has no result field.

Fixes #14822

Checklist

Release Notes

Notes: none

@electron-cation electron-cation Bot added documentation 📓 semver/patch backwards-compatible bug fixes new-pr 🌱 PR opened recently labels Aug 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ This PR contains unsigned commits. This repository enforces commit signatures
for all incoming PRs. To get your PR merged, please sign those commits
(git rebase --exec 'git commit -S --amend --no-edit -n' @{upstream}) and force push them to this branch
(git push --force-with-lease)

For more information on signing commits, see GitHub's documentation on Telling Git about your signing key.

@github-actions github-actions Bot added the needs-signed-commits Currently some or all of the commits in this PR are not signed label Aug 22, 2026
@JACOBIAN01
JACOBIAN01 force-pushed the docs/debugger-sendcommand-behavior branch from 9f06be8 to af943d8 Compare August 22, 2026 08:15
@github-actions github-actions Bot removed the needs-signed-commits Currently some or all of the commits in this PR are not signed label Aug 22, 2026
@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label Aug 23, 2026
Comment thread docs/api/debugger.md Outdated

Send given command to the debugging target.

**Notes:**

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.

Nit: the API docs use > [!NOTE] callouts for notes (about 195 uses in docs/api). Can we use that form here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the feedback. Updated to use the [!NOTE] alert syntax to
match the convention used elsewhere in docs/api (referenced
docs/api/desktop-capturer.md for the multi-point formatting). Pushed in
aa3dea1.

@JACOBIAN01
JACOBIAN01 force-pushed the docs/debugger-sendcommand-behavior branch from 15ab9a9 to aa3dea1 Compare August 28, 2026 04:08

@MarshallOfSound MarshallOfSound 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.

Doesn't seem to render correctly? Check the markdown syntax

@JACOBIAN01

Copy link
Copy Markdown
Contributor Author

You're right, thank you for catching that. The cause: the
markdownlint-disable comment line wasn't prefixed with >, so it split
the blockquote into two separate blocks instead of one, which stopped
GitHub from recognizing it as a [!NOTE] alert at all (it rendered as
plain blockquoted text instead).

Fixed by prefixing that comment line with > too, keeping it inside the
same blockquote. Verified the corrected output through GitHub's markdown
render API before pushing, this time. Pushed in 0618ff0.

@MarshallOfSound MarshallOfSound added target/44-x-y PR should also be added to the "44-x-y" branch. target/45-x-y PR should also be added to the "45-x-y" branch. labels Sep 4, 2026
@MarshallOfSound
MarshallOfSound enabled auto-merge (squash) September 4, 2026 06:41
@MarshallOfSound MarshallOfSound self-assigned this Sep 4, 2026
Documents two long-standing but undocumented behaviors of
debugger.sendCommand():

- Commands sent before the target has navigated may not resolve
  until navigation occurs.
- Commands whose protocol response has no `result` data resolve
  with an empty object (`{}`), not `null` or `undefined`.

Both behaviors were originally reported in electron#14810 and electron#14811
(closed as working-as-intended) and re-verified against current
Electron's Promise-based sendCommand API before writing this up.

Fixes electron#14822
…correctly

The disable comment wasn't prefixed with `>`, which split the blockquote
into two separate blocks on GitHub's renderer instead of one alert box.
Verified via the markdown render API before and after.
auto-merge was automatically disabled September 4, 2026 12:32

Head branch was pushed to by a user without write access

@JACOBIAN01
JACOBIAN01 force-pushed the docs/debugger-sendcommand-behavior branch from 0618ff0 to 69fda7e Compare September 4, 2026 12:32
@JACOBIAN01

Copy link
Copy Markdown
Contributor Author

The workflow runs need re-approval after the rebase (still showing
action_required). Could someone approve them when they get a chance?

@MarshallOfSound
MarshallOfSound enabled auto-merge (squash) September 5, 2026 22:15
@MarshallOfSound
MarshallOfSound merged commit 1a285fc into electron:main Sep 5, 2026
46 checks passed
@welcome

welcome Bot commented Sep 5, 2026

Copy link
Copy Markdown

Congrats on merging your first pull request! 🎉🎉🎉

@release-clerk

release-clerk Bot commented Sep 5, 2026

Copy link
Copy Markdown

No Release Notes

@trop

trop Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "44-x-y", please check out #53605

@trop trop Bot added in-flight/44-x-y and removed target/44-x-y PR should also be added to the "44-x-y" branch. labels Sep 5, 2026
@trop

trop Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "45-x-y", please check out #53606

@trop trop Bot added in-flight/45-x-y merged/45-x-y PR was merged to the "45-x-y" branch. merged/44-x-y PR was merged to the "44-x-y" branch. and removed target/45-x-y PR should also be added to the "45-x-y" branch. in-flight/45-x-y in-flight/44-x-y labels Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

46-x-y documentation 📓 merged/44-x-y PR was merged to the "44-x-y" branch. merged/45-x-y PR was merged to the "45-x-y" branch. semver/patch backwards-compatible bug fixes

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

better documentation for Debugger.sendCommand callback behavior

3 participants