fix(extension): make captcha and token capture work on flow.google.com - #13
Open
santoshray02 wants to merge 3 commits into
Open
fix(extension): make captcha and token capture work on flow.google.com#13santoshray02 wants to merge 3 commits into
santoshray02 wants to merge 3 commits into
Conversation
fix: recognize current Flow host and preserve upload failures
Generation had been failing for a week with CAPTCHA_FAILED: CONTENT_TIMEOUT even though /health reported healthy. Three separate causes, all from the move from labs.google/fx/tools/flow to flow.google.com: - The Flow bearer is only observable during the labs.google -> flow.google.com handoff. Reloading a flow.google.com tab never re-captures it, so the token was never obtained (has_flow_key false) and could never refresh. Token refresh now drives an extension-owned tab through TOKEN_URL. - reCAPTCHA Enterprise is only loaded on /project/<id> pages, never on the home page the old FLOW_URL now redirects to. On-demand tabs open the request's projectId (or the last project page seen), and project tabs are preferred over other Flow tabs. - The first tab matching a Flow URL was used blindly. A tab with a dead bridge (opened before an extension reload, or never loaded injected.js) swallowed GET_CAPTCHA for 25s. Tabs are now pinged (PING_BRIDGE -> FLOW_AGENT_PING/PONG) before use and skipped if they do not answer. Hardening found necessary while debugging: - Every await on the tab-lookup path is bounded (withTimeout) so one Chrome API call that never settles cannot park the shared getOrOpenFlowTab promise and silently stall every later request. - GET_CAPTCHA is re-dispatched until injected.js answers (it loads async; a first dispatch could be lost); injected.js dedups by requestId and caps grecaptcha.execute at 15s. - The Google API fetch and callback delivery carry timeouts. - The last 200 '[Flow Agent]' console lines persist to chrome.storage.local.debugLog so stalls can be diagnosed after the fact. Verified end to end: a 4s text-to-video clip generated in 88s through the extension (credits 1050 -> 1043). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GkWggBWEKrNTR4B5opZ3bo
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
Generation had been failing for a week with
CAPTCHA_FAILED: CONTENT_TIMEOUTwhile/healthkept reportinghealthy. Three separate causes, all fallout from the move fromlabs.google/fx/tools/flowtoflow.google.com:labs.google→flow.google.comhandoff. Reloading aflow.google.comtab never re-captures it, so the token was never obtained (has_flow_key: false) and could never refresh. Token refresh now drives an extension-owned tab throughTOKEN_URL./project/<id>pages, never on the home page the oldFLOW_URLnow redirects to. On-demand tabs open the request'sprojectId(or the last project page seen), and project tabs are preferred over other Flow tabs.injected.js) swallowedGET_CAPTCHAfor 25 s. Tabs are now pinged (PING_BRIDGE→FLOW_AGENT_PING/PONG) before use and skipped if they do not answer.Hardening found necessary while debugging
withTimeout) so one Chrome API call that never settles cannot park the sharedgetOrOpenFlowTabpromise and silently stall every later request.GET_CAPTCHAis re-dispatched untilinjected.jsanswers (it loads async; a first dispatch could be lost);injected.jsdedups by requestId and capsgrecaptcha.executeat 15 s.[Flow Agent]console lines persist tochrome.storage.local.debugLogso stalls can be diagnosed after the fact.Verification
grecaptcha.enterpriseis present onflow.google.com/project/…and absent onflow.google.com/(0 recaptcha scripts after 20 s); the bearer was captured only via thelabs.googlehandoff.node --checkclean onbackground.js,content.js,injected.js;tests/test_extension_flow_urls.py(2 new tests) passes.Related: #10 (captcha/host findings), follows #11.
🤖 Generated with Claude Code
https://claude.ai/code/session_01GkWggBWEKrNTR4B5opZ3bo