Skip to content

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

Closed

Description

@AdamMusa

Summary

ruflet run --web and ruflet run --desktop fail with "client not found" when the prebuilt client is already cached, the periodic update check is due (every 6 hours by default), and GitHub cannot be reached: offline, a DNS failure, a 5xx, or the unauthenticated API rate limit (60 requests/hour; each check makes 4 API calls). The cache is still complete on disk, and the run goes back to working once the network does, or when the check is not due, or with RUFLET_CLIENT_AUTO_UPDATE=0.

Seen on main (dd924eb) and in the published gem 0.0.23.

Reproduce

  1. Have a complete prebuilt web client cached at ~/.ruflet/client/<version>/<platform>/web (index.html plus main.dart.js), with a manifest.json whose checked_at is more than 6 hours old. Or set RUFLET_CLIENT_UPDATE_INTERVAL=0.
  2. Make GitHub unreachable, for example export http_proxy=http://127.0.0.1:9 HTTP_PROXY=http://127.0.0.1:9 (connection refused).
  3. Run ruflet run main.rb --web in an app created by ruflet new.

Actual:

Prebuilt client bootstrap failed: Errno::ECONNREFUSED: Failed to open TCP connection to 127.0.0.1:9 (Connection refused - connect(2) for "127.0.0.1" port 9)
Web client build not found and prebuilt download failed.
Build one with `ruflet build web`, or set RUFLET_CLIENT_DIR.

The exit status is 1, and the cached web/ directory is still on disk. ruflet run main.rb --desktop prints Desktop client executable not found. instead of launching the cached app. When GitHub answers 503 or 403, the first line reads Prebuilt client bootstrap failed: RuntimeError: GitHub API failed (503) instead.

Expected

A cache that passes prebuilt_assets_present? is still used when the optional freshness check cannot run. The README says the client channel is checked "at most once every six hours", so the check is a refresh, not a requirement.

Cause

packages/ruflet/lib/ruflet/cli/run_command.rb, ensure_prebuilt_client:

  • In the cache_ready branch, a nil from fetch_release_for_version already falls back to the cache: release.nil? marks the cache checked and returns cache_root.
  • release_by_tag rescues errors and returns nil, but release_latest does not. fetch_release_for_version always calls release_latest last, so a network error or non-2xx response raises out of it.
  • The method-level rescue StandardError then returns nil, so the cached client is never returned and the run caller reports it missing.

Scope note

ruflet update goes through the same method. There, failing to check should stay a failed update (exit 1, "Failed to update web client for macos"). Reporting "Updated ..." from a check that never ran would be misleading. Only the run path should fall back to the cache.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions