Skip to content

fix: name the unreachable host when a scaffold fetch fails - #195

Merged
Bccorb merged 1 commit into
mainfrom
fix/name-unreachable-fetch-hosts
Sep 5, 2026
Merged

fix: name the unreachable host when a scaffold fetch fails#195
Bccorb merged 1 commit into
mainfrom
fix/name-unreachable-fetch-hosts

Conversation

@Bccorb

@Bccorb Bccorb commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Problem

seamless init reported a bare Error: fetch failed whenever one of its network reads was
rejected at the connection level, giving no way to tell what was unreachable:

Creating project in /tmp/.../smoke
Error: fetch failed

There are three remote reads on the scaffold path, and the message was identical for all three:

  1. openRemoteSource in src/core/templates.ts, fetching registry.json
  2. ensureArchive in the same file, downloading the templates .zip
  3. fetchEnvExample in src/core/fetch.ts, fetching the auth server's .env.example

Each already handles a non-ok HTTP response with a message naming the status and the URL. What
was missing is the connection-level rejection: fetch throws TypeError: fetch failed and that
propagated untouched to the top-level handler in src/index.ts.

This showed up repeatedly while building the scaffold smoke job (#192).

Change

A fetchRemote(url, purpose) helper in src/core/fetch.ts wraps the GET and turns a
connection-level rejection into a message naming the URL, what the CLI wanted from it, and the
network as the likely cause, in the style loginFlow.ts's request() already uses. The original
error is kept as the thrown error's cause. All three call sites go through it. Non-ok responses
keep the messages they had.

Verification

npm run build and npm test pass (979 tests). New unit tests cover all three messages, and each
path was also exercised end to end against the built CLI with only the failing host blocked:

Error: Could not reach https://raw.githubusercontent.com/fells-code/seamless-templates/v0.9.0/registry.json to read the template registry. Check your network connection.
Error: Could not reach https://github.com/fells-code/seamless-templates/archive/v0.9.0.zip to download the project templates. Check your network connection.
Error: Could not reach https://raw.githubusercontent.com/fells-code/seamless-auth-api/v0.7.1/.env.example to read the auth server's env.example. Check your network connection.

Changeset: patch.

`seamless init` makes three remote reads (the template registry, the templates
archive, and the auth server's .env.example). A connection-level failure in any
of them rejected with a bare `TypeError: fetch failed`, which reached the
top-level handler as "Error: fetch failed" and named neither the host nor which
read had failed.

Route all three through a `fetchRemote` helper that reports the URL, what the CLI
wanted from it, and the network as the likely cause. Non-ok responses keep their
existing messages.
@Bccorb
Bccorb merged commit 3a03f98 into main Sep 5, 2026
3 checks passed
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.

1 participant