Skip to content

A hub that cannot be reached is a formatted error, not a raw TypeError - #1428

Merged
Lorenzobattistela merged 2 commits into
bendlang:mainfrom
HamedShams:hub-unreachable-error
Oct 9, 2026
Merged

Lorenzobattistela merged 2 commits into
bendlang:mainfrom
HamedShams:hub-unreachable-error

Conversation

@HamedShams

@HamedShams HamedShams commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Half of #1401: the error message. The other half, a bound on the fetch itself, is in bend.ts and is still open (see the end).

bend f.bend with a 0x… hash import and an unreachable hub printed Bun's exception class as the whole error:

SOME PROOFS FAIL
TypeError: Unable to connect. Is the computer able to access the url?

The name@version path already formats the same condition, and hub_ask already words it as "could not be reached", so book_err now recognises a failed hub fetch and prints:

SOME PROOFS FAIL
Error: http://127.0.0.1:1 could not be reached

The check is on Bun's fetch rejection, a TypeError that carries a code (ConnectionRefused and ENOTFOUND in the two cases below); no bend Err or RangeError has one, so nothing else is caught by it.

Checked with BEND_HUB=http://127.0.0.1:1 and BEND_HUB=http://nonexistent.invalid. A bogus hash against the real hub still prints the formatted a file at … hashing to … error, and a normal file runs as before. bun gates/repo.ts passes (main.ts at 10,365 ttok of 16,000), and tsc reports the same 12 pre-existing errors with and without the change.

I did not touch bend.ts, so the fetch timeout in hub_get stays as it is; that part of #1401 is still open.

bend f.bend with a 0x… hash import and an unreachable BEND_HUB printed
Bun's exception class as the whole error. The name@version path already
formats the same condition, and hub_ask already words it as "could not
be reached", so book_err now recognises a failed hub fetch (Bun's fetch
rejects with a TypeError carrying a code) and prints the same line.
@Lorenzobattistela Lorenzobattistela self-assigned this Oct 9, 2026
@Lorenzobattistela

Copy link
Copy Markdown
Collaborator

Hey @HamedShams , thanks for the PR. I understand that you decided not to touch bend.ts, but the fix outside it is closer to patching the symptom. Besides, catching all errors could possibly catch unrelated type errors that are not about the hub and throw. I decided to commit moving your fix to bendhub and adding the timeout as well.

@Lorenzobattistela
Lorenzobattistela merged commit 1c521ed into bendlang:main Oct 9, 2026
1 check passed
@HamedShams

Copy link
Copy Markdown
Contributor Author

Hey @HamedShams , thanks for the PR. I understand that you decided not to touch bend.ts, but the fix outside it is closer to patching the symptom. Besides, catching all errors could possibly catch unrelated type errors that are not about the hub and throw. I decided to commit moving your fix to bendhub and adding the timeout as well.

Makes sense and fair point on the broad catch. Handling it in hub_get gives the same kind of formatted error the name@version path already had, and thanks for adding the timeout as well.

Is anything left on #1401, or can it be closed?

@Lorenzobattistela

Copy link
Copy Markdown
Collaborator

Closed it, thanks for pointing out.

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.

2 participants