Skip to content

fix(cards): retry card.get() until reload token appears in HTML#3274

Merged
npow merged 1 commit into
masterfrom
npow/fix-card-component-refresh-timing
Jun 17, 2026
Merged

fix(cards): retry card.get() until reload token appears in HTML#3274
npow merged 1 commit into
masterfrom
npow/fix-card-component-refresh-timing

Conversation

@npow

@npow npow commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

CardComponentRefreshTest has 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_card returns 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 subsequent assert_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

  • Existing card-refresh tests pass locally
  • CardComponentRefreshTest no longer flakes in CI across multiple re-runs
  • CardWithRefreshTest (similar pattern in card_refresh_test.py) is unaffected

🤖 Generated with Claude Code

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-apps

greptile-apps Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Fixes a race condition in CardComponentRefreshTest where card.get() was called once immediately after try_to_get_card returned, but the async background refresh process might not have finished writing the new reload token into the HTML yet.

  • Replaces the single card.get() call with a polling loop that retries up to 60 seconds, breaking early once _reload_tok appears in the returned HTML or the deadline expires.
  • The subsequent assert_equals(_reload_tok in card_html, True) assertion is preserved intact, so a genuine failure still surfaces clearly — it just no longer races against the writer.

Confidence Score: 5/5

Safe 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

Filename Overview
test/core/tests/card_component_refresh_test.py Adds a polling loop (up to 60 s) before the first reload-token assertion so card.get() is retried until the async card-refresh writer has flushed the token into HTML

Reviews (1): Last reviewed commit: "fix(cards): retry card.get() until reloa..." | Re-trigger Greptile

@npow
npow merged commit 9088ec4 into master Jun 17, 2026
54 checks passed
@npow
npow deleted the npow/fix-card-component-refresh-timing branch June 17, 2026 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant