feat: add iframe support for Apollo Client detection#1797
Open
feat: add iframe support for Apollo Client detection#1797
Conversation
#1764 Bundle Size — 2.01MiB (+0.07%).26712e0(current) vs 8961f38 main#1758(baseline) Warning Bundle contains 14 duplicate packages – View duplicate packages Bundle metrics
Bundle size by type
Bundle analysis report Branch feat/iframe-support Project dashboard Generated by RelativeCI Documentation Report issue |
commit: |
jerelmiller
reviewed
Jan 28, 2026
| port.onDisconnect.addListener(() => { | ||
| ports[tabId].disconnectPorts?.(); | ||
| ports[tabId].tab = null; | ||
| ports[tabId].tabPorts.delete(port); |
Member
There was a problem hiding this comment.
Note to self to dive in a bit deeper tomorrow:
I wonder if there is a chance to use the frameId as part of this identifier instead of using a Set. The idea is that if we can beef up the id a bit more, hopefully that would simplify some of the handling in other places where we don't have to try and ignore some messages due to it broadcasting to all frames on the same tab ID.
aff9c7d to
26712e0
Compare
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.
Summary
This PR enables
apollo-client-devtoolsto detect and interact with Apollo Clients running inside same-origin iframes, in addition to the main window.Problem
Previously we only detected clients in the top-level window. If a page had iframes with their own Apollo Client instances, those clients were invisible to the extension.
Solution
all_frames: trueto content scripts sotab.jsandhook.jsrun in every frame (main window + iframes)background.tsfrom tracking a singletabport per tab to aMap<tabPorts, frameId>per tab, enabling multiple frames to connect while tracking which frame each port belongs toclientFrames: Map<clientId, frameId>to track which Apollo Client belongs to which frame, enabling targeted message routinggetClientshandler inhook.tsusesSKIP_RESPONSEso frames without Apollo Clients don't pollute discovery responsesFiles Changed
all_frames: trueall_frames: trueSKIP_RESPONSEsymbol + handler logic to skip sending responsesSet<tabPorts>-->Map<Port, frameId>, addclientFramesmapping, implement targeted routingSKIP_RESPONSEtogetClientshandler for frames without clientsAutomated Tests Added
Two new unit tests in
src/extension/__tests__/rpc.test.ts:does not send response when handler returns SKIP_RESPONSESKIP_RESPONSE, no RPC response message is postedSKIP_RESPONSE allows handler to be re-registered after unsubscribeSKIP_RESPONSEcan be properly unsubscribed and re-registeredManual Verification Steps
Single frame (regression test)
Multi-frame detection
npm run start:devnpm run chromehttp://localhost:3000Targeted routing verification
frameIdin console logs in dev mode)Limitations
all_frames: trueonly works for same-origin iframes. Cross-origin iframes remain invisible.References