akiomik / akiomik/nosvelte

The module-level app store makes rxNostr a process-wide singleton

オープン
#88 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
bug
主要言語
TypeScript
スター
29
フォーク
3
平均マージ
3時間 5分
マージ済み PR(30日)
11

説明

`src/lib/stores/app.ts:9`

```ts
export const app = writable<{ rxNostr: RxNostr }>();
```

`NostrApp` writes to it from a reactive statement
(`src/lib/components/NostrApp.svelte:33-36`) and all twelve data components read
`$app.rxNostr` from it. Because this is module state rather than Svelte context, it
is shared by everything running in the same module instance.

**SSR cross-request leak.** Module state is shared across concurrent SSR requests on
one worker. `NostrApp`'s `$:` block runs during SSR, so request A's `rxNostr` can be
observed by request B. The demo hides this with `export const ssr = false`
(`src/routes/+layout.ts`); library consumers get no such protection and the README
does not mention it.

**Only one instance can exist.** Two ``s — side by side or nested — mean
last writer wins. The first app's descendants then use the second app's `rxNostr`
and relays, while their queries live in the first app's `QueryClient`, which *is*
context-scoped. Two scoping mechanisms that can disagree.

Determined by code reading; the QueryClient half is confirmed by the adapter using
`setContext`.

## Direction

Publish `rxNostr` through `setContext`/`getContext`, the same mechanism
`QueryClientProvider` already uses, so that scope follows the component tree.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

Start with src/lib/stores/app.ts:9 and src/lib/components/NostrApp.svelte:33-36, then inspect the twelve data components that read $app.rxNostr. Compare their scope with the QueryClientProvider adapter's setContext usage. The work is done when rxNostr follows the component tree for nested or side-by-side NostrApp instances and does not leak between SSR requests.

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

評価

技術スタック
typescript
領域
frontend
issue の種類
リファクタリング
難易度
4/5
見積もり時間
3〜5日
活発さ
静か
明瞭さ
明確に書かれている
初心者へのやさしさ
55/100

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

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