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

オープン
#1,933 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
react, typescript

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
TypeScript
スター
5
フォーク
4
平均マージ
1日 19時間
マージ済み PR(30日)
144

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

HarperFast/studio のほかの issue

HarperFast/studio の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。