Skip to content

Test/network - #149

Open
gurpreet319 wants to merge 6 commits into
developfrom
test/network
Open

gurpreet319 wants to merge 6 commits into
developfrom
test/network

Conversation

@gurpreet319

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI lite review requested due to automatic review settings September 23, 2026 10:11
@gurpreet319
gurpreet319 requested a review from a team as a code owner September 23, 2026 10:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Unresolved critical threading, connection-lifetime, capture, and API-compatibility issues block approval.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 4 High severity · 4 Medium severity

Open (8)
What changed in this PR

Adds live network monitoring and HAR export to the NativeScript inspector, with native request-metric streaming.

Changes:

  • Adds Network panel rendering and HAR export.
  • Streams metrics through the inspector WebSocket.
  • Adds runtime capture state, serialization, and delivery APIs.
File Changes and final findings
utils/​nativejsinspector.html Adds Network UI and HAR export. Moderate: harPickTiming misinterprets explicit *Ms values (3 votes); rendering 2,000 rows per request causes O(n²) DOM work (1 vote); disconnect does not disable capture (2 votes); Transfer size uses outgoing headers (1 vote); HAR timestamps use export time instead of request time (1 vote).
src/​jsc/​JavaScriptUtils.cpp Adds metric capture and toggle behavior. Critical: inspector capture remains gated by environment variables (3 votes); ETHAN_LOGGING_PIPE changes collection and logging behavior, exposing request metadata (1 vote). Moderate: JSRuntimeDownloadMetrics breaks its existing query contract (3 votes).
src/​jsc/​JavaScriptContext.cpp Adds metric serialization and forwarding. Critical: callbacks access connections and send WebSocket data off the owning thread, risking races and lifetime errors (1 vote). Moderate: legacy metric dumping is skipped without inspector capture (3 votes); streaming unconditionally appends metrics to the log, causing I/O, growth, and metadata exposure (1 vote).
src/​InspectorHTTPServer.cpp Adds network event delivery. Critical: onMetricsData accesses connections off the inspector thread and can race with unref/send operations (2 votes).
include/​jsc/​JavaScriptContext.h Adds capture-state declarations. Moderate: declares std::mutex without directly including <mutex> (1 vote).
include/​InspectorHTTPServer.h Declares the network event delivery API.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/InspectorHTTPServer.cpp Outdated
Comment on lines +747 to +751
SoupWebsocketConnection* targetConnection = nullptr;
for (const auto& pair : m_connections) {
if (pair.second == globalContext) {
targetConnection = pair.first;
break;
Comment on lines +655 to +657
#ifdef REMOTE_INSPECTOR_ENABLE
InspectorHTTPServer::singleton().sendNetworkMetric(mContext, params.str().c_str());
#endif
Comment thread src/jsc/JavaScriptUtils.cpp
Comment thread src/jsc/JavaScriptUtils.cpp
Comment thread src/jsc/JavaScriptContext.cpp Outdated
Comment on lines +628 to +632
std::lock_guard<std::mutex> lock(mNetworkMetricsMutex);
if (!mNetworkCaptureEnabled) {
// Recording is off (inspector Network tab inactive) — drop without storing.
delete net;
return;
Comment on lines +726 to +728
bool enabled = (numArgs >= 1) ? args[0].toBool() : false;
jscContext->setNetworkCaptureEnabled(enabled);
if (result) *result = true;
Comment on lines +297 to +299
// Keep network capture enabled for the whole inspector session,
// similar to console logging.
setNetworkCapture(true);
Comment on lines +575 to +580
function harPickTiming(flat, keys) {
for (const key of keys) {
if (flat[key] !== undefined) return harToMillis(flat[key]);
}
return -1;
}
Copilot AI review requested due to automatic review settings September 23, 2026 10:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Critical and moderate unresolved issues affect compilation, data privacy, API compatibility, and thread safety.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 6 High severity · 4 Medium severity

Open (10)
Previously missed (2)

In code that hasn't changed since last review

Medium severity Environment-enabled network diagnostics are incorrectly discarded

src/​jsc/​JavaScriptContext.cpp:671

When NATIVEJS_DUMP_NETWORKMETRIC or ETHAN_LOGGING_PIPE is set, the request producer still creates metrics, but mNetworkCaptureEnabled starts false unless the inspector sends the new setter. This branch deletes those metrics, so the existing environment-driven diagnostics no longer collect anything in headless or non-inspector runs; preserve the environment opt-in separately from the inspector flag.

Medium severity HAR content length reports request size as response size

utils/​nativejsinspector.html:459

entry.headers is serialized from rtHttpRequest::headers() (the outgoing request headers), so a Content-Length found here is the upload/request-body length, not the response transfer size shown by this column. POST/PUT rows will report the wrong direction; use a response size metric or response headers, or label this as request size.

Comment thread include/jsc/JavaScriptContext.h
InspectorHTTPServer::singleton().sendNetworkMetric(mContext, params.c_str());
#endif

dumpNetworkMetricData(net, this->getUrl());
Copilot AI review requested due to automatic review settings September 23, 2026 11:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The review identified a compilation blocker, security and privacy risks, concurrency issues, and functional regressions.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 8 High severity · 4 Medium severity

Open (12)
Previously missed (1)

In code that hasn't changed since last review

Medium severity HAR entries lose original request timestamps

utils/​nativejsinspector.html:652

Every exported entry is assigned the time of the HAR export, not when that request occurred. A HAR containing multiple completed requests therefore loses request chronology and makes all requests appear to start simultaneously; record the capture timestamp with each streamed metric and use it here.

if (soup_websocket_connection_get_state(conn) == SOUP_WEBSOCKET_STATE_OPEN) {
soup_websocket_connection_send_text(conn, evtStr.c_str());
}
sendText(pair.first, evtStr);
if (j) {
params << ",";
}
params << "\"" << jsonEscape(net.headers[j].cString()) << "\"";
Copilot AI review requested due to automatic review settings September 23, 2026 11:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Unresolved critical connection-lifetime and public-binding compatibility issues, along with capture, privacy, and HAR correctness issues, block approval.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 10 High severity · 4 Medium severity

Open (14)
Previously missed (1)

In code that hasn't changed since last review

Medium severity NetworkMetrics.headers is populated from rtHttpRequestEx::headers() (the outgoing request…

utils/​nativejsinspector.html:459

NetworkMetrics.headers is populated from rtHttpRequestEx::headers() (the outgoing request headers), not response headers. Consequently a request body's Content-Length can be shown as the response transfer size, even though it is unrelated to downloaded bytes. Only use a response byte metric/header here, or omit this shortcut rather than reporting a misleading size.

Comment on lines +109 to +113
SoupWebsocketConnection* InspectorHTTPServer::findConnectionForContext(JSGlobalContextRef context)
{
std::lock_guard<std::mutex> connectionsLock(m_connectionsMutex);
for (const auto& pair : m_connections) {
if (pair.second == context) {
Comment thread src/jsc/JavaScriptUtils.cpp
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.

2 participants