Skip to content

inspector: return errors when CDP protocol event emission fails#62162

Open
islandryu wants to merge 2 commits intonodejs:mainfrom
islandryu:returnError
Open

inspector: return errors when CDP protocol event emission fails#62162
islandryu wants to merge 2 commits intonodejs:mainfrom
islandryu:returnError

Conversation

@islandryu
Copy link
Member

@islandryu islandryu commented Mar 9, 2026

Previously, there was no feedback when functions that emit events such as Network.webSocketCreated failed. This change modifies the behavior so that feedback can be obtained when such failures occur.

Since an event may be emitted to multiple sessions, instead of throwing an error directly, the errors are returned as an array.

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/inspector

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Mar 9, 2026
@codecov
Copy link

codecov bot commented Mar 9, 2026

Codecov Report

❌ Patch coverage is 96.73913% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.73%. Comparing base (3725bd2) to head (d265030).
⚠️ Report is 24 commits behind head on main.

Files with missing lines Patch % Lines
src/inspector/network_agent.cc 96.96% 2 Missing ⚠️
src/inspector/dom_storage_agent.cc 96.15% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #62162      +/-   ##
==========================================
+ Coverage   89.65%   89.73%   +0.07%     
==========================================
  Files         676      676              
  Lines      206543   206666     +123     
  Branches    39547    39559      +12     
==========================================
+ Hits       185184   185448     +264     
+ Misses      13480    13386      -94     
+ Partials     7879     7832      -47     
Files with missing lines Coverage Δ
src/inspector/dom_storage_agent.cc 83.06% <96.15%> (+33.37%) ⬆️
src/inspector/network_agent.cc 88.03% <96.96%> (+26.35%) ⬆️

... and 37 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Isolate* isolate = Isolate::GetCurrent();
if (!ObjectGetProtocolString(context, storage_id_obj, "securityOrigin")
.To(&security_origin)) {
ThrowEventError(isolate, "Missing securityOrigin in storageId");
Copy link
Member

@legendecas legendecas Mar 9, 2026

Choose a reason for hiding this comment

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

IIUC, this would throw an identical error for each session connected. Can we validate the object shape once so that the error is only thrown once? This would also prevent returning an array of errors in the JS API.

Copy link
Member Author

Choose a reason for hiding this comment

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

If errors that depend on session-specific state are introduced in the future, this may need to be changed. However, since we currently only perform type checks, would it make sense to throw the error directly?
I’ve added a commit to implement this change.

-->

* `params` {Object}
* Returns: {Array} An array of errors from each session
Copy link
Member

Choose a reason for hiding this comment

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

Preferrably, an array of errors should be thrown as AggregateError.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants