-
Notifications
You must be signed in to change notification settings - Fork 21
feat(network-activity-plugin): show http network requests on boot #143
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?
feat(network-activity-plugin): show http network requests on boot #143
Conversation
|
@dprevost-LMI is attempting to deploy a commit to the Callstack Team on Vercel. A member of the Team first needs to authorize it. |
| **/dist | ||
| **/coverage |
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.
To revert, waiting on the merge of #130
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.
|
Unfortunately, it's not going to work in some cases. There is a slight delay between the client becoming available and the other side being ready to accept messages. In other words, useRozeniteDevToolsClient may return a client instance and allow you to send messages, but the other side may not be listening yet. I need to refactor the bridge to include some sort of handshake mechanism so both sides can confirm that they’re ready to handle communication correctly. |
I performed a few iterations and flushed the queue when I received the |
|
I have reached a point where this solution, although not entirely finalized, is the one I suggest. |
539c61d to
f67dea9
Compare
packages/network-activity-plugin/src/react-native/useNetworkActivityDevTools.ts
Outdated
Show resolved
Hide resolved
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 PR is being reviewed by Cursor Bugbot
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
Bug: HTTP Inspector Fails to Auto-Enable Recording
The HTTP network inspector is never automatically enabled when the component mounts, even though isRecording defaults to true in the store. The removed code that checked isRecordingEnabledRef.current and called networkInspector.enable() was necessary to enable the inspector on initial mount and after hot reloads. WebSocket and SSE inspectors still have this logic (lines 121-123 and 159-161), creating an inconsistency where HTTP requests won't be captured until the user manually toggles recording, while WebSocket and SSE connections will be captured automatically.
packages/network-activity-plugin/src/react-native/useNetworkActivityDevTools.ts#L78-L89
rozenite/packages/network-activity-plugin/src/react-native/useNetworkActivityDevTools.ts
Lines 78 to 89 in 5dfcf37
| useEffect(() => { | |
| if (!client || !isHttpInspectorEnabled) { | |
| return; | |
| } | |
| const networkInspector = getNetworkInspector(client); | |
| return () => { | |
| networkInspector.dispose(); | |
| }; | |
| }, [client, isHttpInspectorEnabled]); |
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 PR is being reviewed by Cursor Bugbot
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
packages/network-activity-plugin/src/react-native/http/network-inspector.ts
Outdated
Show resolved
Hide resolved
0ba0550 to
319ce0c
Compare
V3RON
left a comment
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 pull request includes not only recording network traffic on boot, but also changing the way how 'long requests' are displayed (status with progress). Please clean it up, so only a single feature remains.
For the implementation, instead of combining traffic inspection and queueing logic, I suggest the following approach:
a) refactor inspectors to share the same API (emit events)
b) provide a special type of an inspector accumulating events and flushing them on demand
c) detect the presence of 'queued inspector' and flush events when plugin client is ready (in practice, when DevTools UI sends some kind of 'hello' message)
type Inspector<TEventMap> = {
enable: () => void;
disable: () => void;
on<TEventType extends keyof TEventMap(type: TEventType, callback: (event: TEventMap[TEventType]) => void);
on(type: '*', callback: (event: TEventMap[keyof TEventMap]) => void);
};
type NetworkInspector = Inspector<NetworkEventMap>;
type QueuedInspector = Inspector & {
flush: () => void;
};
const networkInspector = createRozeniteNetworkInspector({
recordOnBoot: true,
});
const websocketInspector = createRozeniteWebSocketInespector();
const useNetworkActivityDevTools = ({ inspectors }) => {
const pluginClient = useRozeniteDevToolsClient({ pluginId: '...' });
useEffect(() => {
inspectors.forEach((inspector) => {
inspector.on('*', (event) => pluginClient.send(event.type, event));
if ('flush' in inspector) {
inspector.flush();
}
});
}, [inspectors, pluginClient]);
}
const App = () => {
useNetworkActivityDevTools({
inspectors: [networkInspector, websocketInspector]
});
}Note: this is pseudo-code, not production-ready 😄
In this approach, the inspector only handles inspection and passing data to the listeners. Queuing is not its concern.
|
I'll proceed to the change as you requested! Just so you know: One thing I was thinking about with this queued client is that if we can make it generic enough, it could be exposed as a generic interface, allowing any package to use it directly and be boot-time compliant. |
020a939 to
c3a31e1
Compare
a) I think I had partially done it with I might reach out to you tomorrow on Discord since it seems blurry in my mind right now! |
Description
Using a queuing mechanism, we can keep booting requests and display them when the inspector panel is ready.
Other:
request-tracker.tsfile.Out of scope:
TODO
withOnBootNetworkActivityRecordingRelated Issue
See #82
Context
We heavily rely on the WebSocket and HTTP requests on boot for our enterprise app, so we totally need this feature, so I took a go for it.
Testing
Final solution
Screen.Recording.2025-11-15.at.6.54.19.PM.mov
Note
Adds boot-time HTTP request capture via a queued client and
withOnBootNetworkActivityRecording, includes progress/timeout support and UI updates, plus docs and playground examples.withOnBootNetworkActivityRecordingand queued client (queued-client-wrapper) to buffer events before DevTools connects;network-inspectorupdated to flush queue on enable.request-tracker(tracking, overrides, response body helpers).request-progress(with loaded/total), handletimeout; wire through store (model,derived,store) and client (shared/client).RequestListshows in-progress percent;Toolbarswaps record/stop icon logic and adds tooltip; default recording enabled.apps/.../utils/network-activity/api.ts; add "Large File" download flow usingapi.getLargeFileand UI tab;main.tsxenables on-boot recording and triggers sample requests..prettierignoreto**/distand**/coverage.Written by Cursor Bugbot for commit 020a939. This will update automatically on new commits. Configure here.