App-wide offline handling: every other mutation still pauses silently while offline

Aperta
#1,933 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
react, typescript

Direzione di ricerca

Start with src/features/auth/failFastOffline.ts to see how networkMode: 'always' and OfflineSubmitError are applied, then find the QueryClient defaults and the global errorHandler. The issue asks for a decision first: a shared mutation default, an offline indicator, or both, so confirm the choice with maintainers before editing. Done means an offline mutation fails fast with a "You're offline" message, offline failures never reach console.error, and the auth behaviour from #1930 still passes.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Follow-up to #1930. That issue fixed the auth forms only.

Problem

React Query's default networkMode is 'online', for queries and for mutations. While onlineManager reports offline, a mutation is paused before its mutationFn runs. isPending and isPaused are both true, nothing is sent, and nothing fails. A query is held in fetchStatus: 'paused'. Studio never renders isPaused anywhere, so every submit button bound to isPending spins with no message for as long as the browser is offline. When the connection comes back, the paused request is sent, often after the person has given up or moved on.

#1930 moved every auth mutation to failFastOffline (src/features/auth/failFastOffline.ts: networkMode: 'always', plus an OfflineSubmitError that the forms show as "You're offline…"). Before that, the only other mutation to opt out was useAddDomainToOrganization (networkMode: 'always'). The rest of the app still uses the default:

  • Organization: create/delete organization, add/edit/delete role, add/remove user from a role, invite or re-invite a user, coupon, delete domain, attach a payment method, the Stripe intent mutations, profile update, organization OAuth settings.
  • Clusters: create/edit cluster, set domains on a cluster, terminate, container start/stop/restart, Finish Setup (useInstanceResetPasswordMutation).
  • Instance config: users, roles, certificates, SSH keys and known hosts, secrets and grants, OIDC trust policies, instance status and restart.
  • Applications: add from template, import/redeploy/activate a staged release, package/download, set file, env values, drop component.
  • Databases: create/delete database and table, insert/put/update/delete records, CSV/import, orphan-blob cleanup.
  • Admin: API tokens, notifications, regions.
  • Navbar sign-out (useLogoutMutation). Left out of #1930 because it also runs the instance sign-out sweep.

The full per-hook list is in #1937, the PR that closes #1930.

One case is worth checking separately. Local Studio (isLocalStudio) talks to the instance that serves it, often on localhost, which still answers when the machine has no network. React Query gates on the browser's online signal, not on whether the target can be reached. So if the connection drops while local Studio is open, every query and mutation pauses, even though the instance is still reachable.

Options

  1. A shared default. Set networkMode: 'always' in the QueryClient's defaultOptions.mutations, and possibly for queries too. Pair it with an offline classification like failFastOffline's, so that the global errorHandler toasts "You're offline" rather than "Outcome unknown" for a request sent while offline, and logs it with console.debug rather than console.error (RUM, #1669). For queries, 'always' loses the automatic refetch when the connection returns, so this may only be right for mutations.
  2. A global offline indicator. A banner bound to onlineManager that says requests are paused until the connection returns. This keeps the default and its automatic resume, but it can't fix a paused submit that has already been abandoned and still fires later.
  3. Both: fail fast on mutations, keep pausing queries, and show the indicator so a paused query reads as "offline" rather than "loading".

Whichever is chosen, keep #1930's rule that an offline failure never reaches console.error.

Lingua principale
TypeScript
Stelle
5
Fork
4
Merge medio
1g 19h
PR unite (30g)
144

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di HarperFast/studio

Tutte le issue di HarperFast/studio

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.