Skip to content

fix: keep using a cached client when the update check cannot reach GitHub - #98

Merged
AdamMusa merged 8 commits into
mainfrom
fix/offline-cached-client
Nov 20, 2026
Merged

AdamMusa merged 8 commits into
mainfrom
fix/offline-cached-client

Conversation

@AdamMusa

Copy link
Copy Markdown
Owner

Fixes #95

Problem

When a complete prebuilt client is cached and its periodic update check is due (6 hours by default), ruflet run --web and ruflet run --desktop call GitHub first. If GitHub cannot be reached (offline, a DNS failure, a 5xx, or the unauthenticated rate limit), release_latest raises. ensure_prebuilt_client turns that error into nil, so the run reports the client as missing even though the cache is still on disk:

Prebuilt client bootstrap failed: RuntimeError: GitHub API failed (503)
Web client build not found and prebuilt download failed.

What changed

  • ensure_prebuilt_client takes a new keyword, use_cache_if_check_fails:, which defaults to false. Only the two run callers pass true: detect_web_client_dir and detect_desktop_client_command.
  • With that keyword, an error from the freshness probe in the cache_ready branch prints one warning and returns the cache: Could not check for a newer client (<reason>); using the cached one.
    • The cache is not marked as checked, so the next run tries again.
  • ruflet update does not pass the keyword. Its error is re-raised into the existing method-level rescue, so it still exits 1 with Failed to update web client for macos. Reporting "Updated ..." from a check that never ran would be misleading.
  • Nothing else changes:
    • release_latest still raises.
    • The uncached offline path is untouched (run-main.rb--web-offline is byte-identical).
    • A check that succeeds, or one that is not due, behaves exactly as before.
  • packages/ruflet/README.md: one added sentence, next to the existing six-hour note.

Behavior changes

Each of these is a clear bug fix (D6). No other existing invocation's output changes:

  • ruflet run main.rb --web with a complete cache, a due check and GitHub unreachable:
    • Before: exit 1, "Web client build not found and prebuilt download failed."
    • After: one warning line on stderr, then the cached client is served (exit 0).
  • ruflet run main.rb --desktop in the same state:
    • Before: "Desktop client executable not found."
    • After: the same warning line, then the cached desktop app is launched.

ruflet update web in the same state is unchanged: exit 1, "Failed to update web client for macos". A new golden pins this.

No app code and no command line change.

How verified

  • Regression tests (packages/ruflet/test/run_command_test.rb). Each stubs github_get_json to fail, so the real release_by_tag/release_latest chain runs.
    • test_run_web_keeps_a_complete_cache_when_the_update_check_cannot_reach_github
    • test_run_desktop_keeps_a_complete_cache_when_the_update_check_cannot_reach_github (macOS layout)
    • test_update_still_fails_when_the_update_check_cannot_reach_github
    • With the fix reverted, the two run tests fail (they get nil) and the update test passes. With the fix, all three pass.
  • H1 goldens (packages/ruflet/test/compat/corpus.rb): three new entries, each with a seeded cache, RUFLET_CLIENT_UPDATE_INTERVAL=0 and the harness network answering 503. They are added at the end of the run and update sections.
    • run-main.rb--web-seeded-due-offline
    • run-main.rb--desktop-seeded-due-offline
    • update-web-seeded-due-offline
    • On unfixed main, the two run goldens show the failure above. The update golden is identical before and after the fix.
  • Full H1 check: ruby test/compat/compat.rb --jobs 4 checked 237 goldens with 0 diffs. That is all 234 existing goldens byte-identical, plus the 3 new ones.
  • Unit suites: every packages/ruflet/test/*_test.rb file, one process per file, has 0 failures and 0 errors.
  • Real network, outside the harness: a temp HOME with a cache checked 7 hours ago, and http_proxy=http://127.0.0.1:9 so every connection is refused.
    • ruflet run main.rb --web now prints the warning and serves the cache.
    • The same setup with RUFLET_CLIENT_AUTO_UPDATE=0, or with a check that is not due, behaves as before.

…tHub

When a complete prebuilt client was cached and its periodic update check
was due, `ruflet run --web` and `--desktop` failed whenever GitHub could
not be reached (offline, DNS failure, 5xx or the unauthenticated rate
limit): release_latest raised, ensure_prebuilt_client turned that into
nil, and the run reported the client as missing although the cache was
intact.

The run callers now pass use_cache_if_check_fails: true, so a failed
probe prints one warning and returns the cache, without marking it
checked so the next run tries again. `ruflet update` keeps failing when
the check cannot run.

Fixes #95
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ruflet run --web/--desktop fails offline with a valid cached client when the periodic update check is due

1 participant