fix(cards): retry card.get() until reload token appears in HTML#3274
Conversation
CardComponentRefreshTest was intermittently failing because try_to_get_card returns as soon as the card file exists, but the async refresh may not have finished writing the new reload token into the HTML yet. Poll card.get() for up to 60 s before asserting the token is present. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Greptile SummaryFixes a race condition in
Confidence Score: 5/5Safe to merge — single-file change confined to a test helper, with no production code touched. The polling loop is logically correct: it breaks on success or deadline expiry, and the hard assertion immediately after still fires so real failures remain visible. The 60-second ceiling is generous compared to what the async writer should need, making it an effective race eliminator without masking real failures. No files require special attention. Important Files Changed
Reviews (1): Last reviewed commit: "fix(cards): retry card.get() until reloa..." | Re-trigger Greptile |
Summary
CardComponentRefreshTesthas been intermittently failing (~40 s) across unrelated PRs in both the OSS repo and Netflix's internal mli-metaflow-custom CI.Root cause:
try_to_get_cardreturns as soon as the card file exists on disk, but the async background refresh process may not have finished writing the new reload token into the HTML yet. The subsequentassert_equals(_reload_tok in card.get(), True)therefore races against the writer and occasionally fails.Fix: Poll
card.get()in a tight loop (up to 60 s) until the expected reload token appears before asserting, eliminating the race condition.Test plan
CardComponentRefreshTestno longer flakes in CI across multiple re-runsCardWithRefreshTest(similar pattern incard_refresh_test.py) is unaffected🤖 Generated with Claude Code