fix(network): say how long capture has been running when the network log is empty - #660
Open
filip131311 wants to merge 3 commits into
Open
fix(network): say how long capture has been running when the network log is empty#660filip131311 wants to merge 3 commits into
filip131311 wants to merge 3 commits into
Conversation
…mpty view-network-logs installs the fetch() interceptor the first time it runs, so traffic the app issued before that is never recorded. The empty result said 'Network interception is active', which reads as a verdict — the app made no requests — when it actually described a state the call had just created. The interceptor now stamps when it started and the read script returns the elapsed window, computed app-side so no host/device clock comparison is involved. The empty result quotes that number instead of picking a threshold: 'recording for 2 ms' reads as 'you have learned nothing yet', 'recording for 14 min' reads as a real empty result, and the same sentence covers both. Three things the log could not previously distinguish are now separate: a window that just opened, a window of unknown length (an interceptor left by an earlier session has no timestamp — defaulting that to 'now' would report 0 ms forever), and nothing recording at all. That last case is why the check moved to the count read: injection is swallowed as non-fatal in two places, so a runtime where it failed was reporting 'interception is active'. Also names the two silent exclusions that make an empty log ambiguous — only fetch() is patched, so an XHR-based client such as axios shows nothing, and Metro's own traffic is filtered out — and replaces the suggestion to reconnect with 'network-inspector-connect', a tool that does not exist.
The test-ui-flow skill told agents to drive the app and then verify with view-network-logs, which is exactly the order that loses the requests.
An npm version difference added 'peer' markers during a local install; this change touches no dependencies.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #633.
The problem
view-network-logsinstalls thefetch()interceptor the first time it runs, so traffic the app issued before that is never recorded. The empty result then said:"Network interception is active" describes a state the call itself had just created. An agent reads that as a verdict — the app made no requests — which is a wrong answer, not a missing feature.
Reproduced live
iPhone 17 Pro sim + RN app. Connected the debugger, then fired three fetches before touching any network tool:
Three completed HTTP 200s, reported as nothing.
There is a second path to the same wrong answer, not in the report:
debugger-reload-metro(or any JS reload) destroys the interceptor and every captured entry —__argent_network_logceases to exist — after which the same misleading message describes data the tool previously held.The fix
The interceptor stamps when it started; the read script returns the elapsed window, computed app-side from two app-side clock reads, so no host/device clock comparison is involved.
The empty result quotes that number instead of picking a threshold:
recording for 2 ms→ you have learned nothing yetrecording for 14 min→ this is a real empty resultSame sentence, no branch, no cliff where an agent's conclusion flips.
Three states the old message could not distinguish are now separate:
0 msforever, reintroducing the same lieThat last case is why the
interceptorInstalledcheck moved up to the count read.Also folded in, because they make an empty log ambiguous in exactly the same way:
fetch()is patched. An app usingXMLHttpRequestdirectly — including axios, whose RN adapter is XHR-based — shows nothing at all. Now stated in the message and the description.localhost/127.0.0.1at the Metro port, so a device reaching Metro over a LAN IP still shows it. Documented rather than widened — widening would hide a user's own API served on the same port.network-inspector-connectdoes not exist. The "interceptor not installed" path told agents to call a tool that appears nowhere else in the tree. That path is reachable only when the runtime reloads between the count read and the page read, so it now says that.Verified on the device, all four branches
fetch() interception has been recording for 2 ms — …… recording for 12.0 s — …installedAt: null, hit for real)… start time is unknown (it was installed by an earlier session) …… fetch() interception is NOT installed …=== NETWORK LOGS (page 1/1, 1 total) ===— unchanged, Metro request still filteredScope
Deliberately not included: arming capture at
debugger-connect. It is a silent behaviour change for every debugger user (patchesglobalThis.fetch, pins up to 2000 response bodies in the app heap) and it does not close the hole — traffic before connect, and after any reload, is still lost, so honest messaging is required either way. Worth its own PR; I'll file a follow-up.Checks
executedirectly, because the existing integration harness synthesizes read-script payloads in TypeScript and so cannot exercise this logicview-network-logs10.0; description kept a static literal, sinceextract-tools.mjsrejects interpolation