Wrap `fetch` call in `try/catch`

Open
#276 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
typescript
Domain
api

Research direction

Start in oxide-api/src/http-client.ts at lines 146-160 and inspect how the fetch call currently propagates failures. Review the linked console issue for the expected handling of non-API errors, then verify that network failures from an offline or throttled browser are handled explicitly without changing normal API error behavior.

Written by the indexing model from the issue text.

Description

In relatively rare situations and through no fault of ours (like network issues) the fetch call here can throw an error. (One way to repro: turn throttling to Offline in Firefox and submit a form.)

https://github.com/oxidecomputer/oxide.ts/blob/7890e4dcb8b8371ca6c5ffefc4ddf77dd660c823/oxide-api/src/http-client.ts#L146-L160

That means an error of arbitrary shape gets thrown up to the web console, which doesn't know what to do with it, and in fact is not aware that this can happen. In practice, this has been ok because we primarly rely on a message property on our ApiError type which is also present on regular Errors. But it would be nice to be able to explicitly handle non-API errors that occur while making an API call. See https://github.com/oxidecomputer/console/issues/2569.

Dominant language
TypeScript
Stars
33
Forks
4
Avg merge
6d 9h
Merged PRs (30d)
4

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from oxidecomputer/oxide.ts

All issues in oxidecomputer/oxide.ts

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.