NostrApp rebuilds its QueryClient reactively, but QueryClientProvider reads it only once
- 主要言語
- TypeScript
- スター
- 29
- フォーク
- 3
- 平均マージ
- 3時間 5分
- マージ済み PR(30日)
- 11
説明
`NostrApp` builds its `QueryClient` in a reactive statement
(`src/lib/components/NostrApp.svelte:31`):
```ts
$: queryClient = new QueryClient(mergedQueryClientConfig);
```
but `QueryClientProvider` reads it only at initialization
(`node_modules/@tanstack/svelte-query/dist/QueryClientProvider.svelte`):
```svelte
onMount(() => { client.mount() })
setQueryClientContext(client) // init only
onDestroy(() => { client.unmount() })
```
So if `queryClientConfig`'s identity ever changes — an inline object literal on the
`` tag is enough — a fresh `QueryClient` is constructed and thrown away:
- descendants keep resolving the original client from context;
- the new client is never `mount()`ed;
- on destroy, `unmount()` runs against the *latest* client (never mounted, so its
`mountCount` goes negative), while the client that actually installed the
focus/online listeners is **never unmounted** — one listener leak per `NostrApp`
lifetime.
`NostrApp` also never clears its cache on destroy.
The same init-only behaviour holds in `@tanstack/svelte-query` v6, so this is not
fixed by upgrading.
Determined by code reading of the installed adapter.
## Direction
Create the `QueryClient` once (not in a reactive statement). If reacting to config
changes is wanted at all, it needs a keyed remount of the provider, not a
reassignment.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
Start in src/lib/components/NostrApp.svelte:31 and inspect how queryClient is created and destroyed. Confirm the provider behavior described in the issue before making the change. Done means each NostrApp lifetime uses one QueryClient, the client is cleaned up on destroy, and changing config identity does not leak listeners or leave a discarded client.
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- frontend
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 静か
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 78/100