-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
inspector: initial support for Network.loadNetworkResource #58077
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Review requested:
|
86ba453
to
435c33f
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #58077 +/- ##
==========================================
- Coverage 90.26% 90.17% -0.10%
==========================================
Files 630 631 +1
Lines 185933 186808 +875
Branches 36450 36672 +222
==========================================
+ Hits 167829 168448 +619
- Misses 10972 11141 +169
- Partials 7132 7219 +87
🚀 New features to boost your workflow:
|
src/inspector/io_agent.cc
Outdated
namespace node { | ||
namespace inspector { | ||
namespace protocol { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit... since we're finally up on c++20, we can start using the more condensed namespace node::inspector::protocol {
syntax where appropriate.
}) | ||
)"; | ||
|
||
auto [r, response, err] = spawnFetchProcess(code, env_, in_url); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not a fan of spawning a Node.js process for each Network.loadNetworkResource
request from devtools frontend. A devtool frontend may call this method multiple times simultaneously if there are several source maps and spawning a Node.js process for each of them seems superfluous and resource draining.
As an alternative, we could expose this as a hook to JS inspector API so that it will be properly covered by environment variables like HTTP_PROXY
and the permission model. Additionally, this allows the JS API hook to filter which domain the process is allowed to send request to.
std::string command = | ||
env->exec_path() + " --eval \"" + code.data() + "\" -- " + url.data(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This command
is not used.
Fixes: #57873
Adds initial support for Network.loadNetworkResource in the inspector.
https://chromedevtools.github.io/devtools-protocol/tot/Network/#method-loadNetworkResource
how to load network resource
Resource fetching is done via a spawned child process to keep the inspector's event loop clean and isolated.
The JavaScript code for the fetch process is currently hardcoded, which may not be ideal, but I couldn't come up with a better approach at this point.
other infomation
If this change is considered acceptable, I will send a follow-up change request to expand the Node.js DevTools target with IO support.
If it is necessary to wait until Network.loadNetworkResource becomes stable in CRDP, please feel free to keep this PR pending.