Repository navigation
Conversation
#2389 Bundle Size — 2.04MiB (+0.16%).2d8db69(current) vs 08f3a19 main#2386(baseline) Warning Bundle contains 16 duplicate packages – View duplicate packages Bundle metrics
Bundle size by type
Bundle analysis report Branch pr/background-routing Project dashboard Generated by RelativeCI Documentation Report issue |
| @@ -74,9 +73,6 @@ function getClientInfo(client: ApolloClient): ApolloClientInfo { | |||
| } | |||
|
|
|||
| handleRpc("getClients", () => { | |||
There was a problem hiding this comment.
Without a routing layer, any frame could previously respond, and any responses after that would be ignored.
commit: |
| continue; | ||
| } | ||
| try { | ||
| tabPort.postMessage(message); |
There was a problem hiding this comment.
Here, starting cache-write recording could throw in sibling frames.
The old code would broadcast anything but RPCMessages, so RPCStartStream got broadcast.
A sibling frame would look up a client it didn’t own and try to read .cache from undefined.
| handleRpc("getClients", () => { | ||
| if (knownClients.size === 0) { | ||
| return SKIP_RESPONSE as any; | ||
| } |
There was a problem hiding this comment.
If no clients were present, this would previously "immediately return", but never send a response, causing the devtools to run into a timeout.
| }); | ||
|
|
||
| if (signal) { | ||
| signal.addEventListener("abort", () => { |
There was a problem hiding this comment.
These were never cleaned up and could cause memory to accumulate.
This moves message routing into a separate
router.ts.Each tab gets a router. Each frame (the "root window" is called "frame" too in this context) is held as a connection, their client ids are tracked.
The router starts tracking which rpc and stream messages actually belong to which source and drops unrelated messages from other sources.
Before this PR,
getClientswould only wait for the fastest frame to respond, and drop all responses from other frames. That is now fixed.Stack created with GitHub Stacks CLI • Give Feedback 💬