diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bd9972a1..eeb0fa3dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## UNRELEASED - CLI - fix: Make `modus --version` just print modus CLI's version [#563](https://github.com/hypermodeinc/modus/pull/563) -- fix: implement retry and caching for CLI downloads [#571](https://github.com/hypermodeinc/modus/pull/571) +- fix: implement retry and caching for CLI downloads [#571](https://github.com/hypermodeinc/modus/pull/571) [#574](https://github.com/hypermodeinc/modus/pull/574) ## UNRELEASED - Runtime diff --git a/cli/src/commands/new/index.ts b/cli/src/commands/new/index.ts index 7a569027a..1e8c1f8be 100644 --- a/cli/src/commands/new/index.ts +++ b/cli/src/commands/new/index.ts @@ -272,7 +272,7 @@ export default class NewCommand extends BaseCommand { this.logError(`Could not find an installed ${sdkText}.`); this.exit(1); } else { - this.logError(`Could not find a locally installed ${sdkText}. Please connect to the internet and try again.`); + this.logError(`Could not find a locally installed ${sdkText}, and you appear to be offline. Please connect to the internet and try again.`); this.exit(1); } } diff --git a/cli/src/util/http.ts b/cli/src/util/http.ts index 688bb44d3..c54e115ad 100644 --- a/cli/src/util/http.ts +++ b/cli/src/util/http.ts @@ -12,9 +12,9 @@ import ky from "ky"; // All outbound HTTP requests in the CLI should be made through functions in this file, // to ensure consistent retry and timeout behavior. -export async function get(url: string, timeout: number | false = 10000) { +export async function get(url: string, timeout: number | false = 5000) { return await ky.get(url, { - retry: 10, // retry 10 times, up to the default 10s timeout (unless overridden) + retry: 4, timeout, }); } diff --git a/cli/src/util/index.ts b/cli/src/util/index.ts index 3e4dfaeec..0775faccf 100644 --- a/cli/src/util/index.ts +++ b/cli/src/util/index.ts @@ -9,14 +9,13 @@ import chalk from "chalk"; import ora, { Ora } from "ora"; - +import dns from "node:dns"; import path from "node:path"; import { Readable } from "node:stream"; import { finished } from "node:stream/promises"; import { createWriteStream } from "node:fs"; import * as http from "./http.js"; import * as fs from "./fs.js"; -import * as vi from "./versioninfo.js"; export async function withSpinner(text: string, fn: (spinner: Ora) => Promise): Promise { // NOTE: Ora comes with "oraPromise", but it doesn't clear the original text on completion. @@ -60,8 +59,7 @@ export async function isOnline(): Promise { if (online !== undefined) return online; try { - // we don't need the result here, just checking if the request is successful - await vi.fetchModusLatest(); + await dns.promises.lookup("releases.hypermode.com"); online = true; } catch { online = false;