relay: the CLOSE-during-mint test synchronises on a 50 ms sleep and can fail under load
維護者通常 1 天內回覆
評估
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 新手友好度
- 35/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 停滯
- 技術堆疊
- rust, typescript
研究方向
Start with crates/nostream-relay/tests/handlers.rs:1135 and inspect the test's CLOSE handling and gate release; then read testing.rs for the existing gate observables and Connection::read_in_flight. Replace the fixed 50 ms delay with a bounded wait for the abort signal or cleared in-flight read. Done when release is ordered after the abort, the timeout reports a clear failure, and the test no longer relies on sleep; pull request #987 is already open.
由索引模型根據 Issue 內容生成。
描述
a_close_during_the_invite_mint_leaves_the_event_but_not_the_read (crates/nostream-relay/tests/handlers.rs:1135, added in #962) synchronises the CLOSE against the invite mint with a fixed sleep:
gate.add_permits(1);
...is preceded only by tokio::time::sleep(Duration::from_millis(50)) after ["CLOSE","invite"] is sent. Nothing confirms the server has processed the CLOSE — i.e. that unsubscribe::handle has run abort_read and set the in-flight read's cancellation — before the gate releases the mint.
Failure mode: a false failure, not a false pass. If a busy runner delays the CLOSE handler past the sleep, the mint resumes first, the handler reaches fetch_and_send with the cancellation not yet set, and the test then observes the stored EVENT and the EOSE it asserts must not arrive. The fix is correct and the test goes red anyway. The window is small (50 ms against a local in-memory store) and the test passed in CI on #962, so this is a flake risk rather than a live defect.
Suggested fix. Wait for a server-side signal instead of for elapsed time. The crate already has the passive half — Connection::read_in_flight(id) is observable — so the options are:
- Poll
fixture.connection(id).read_in_flight("invite") == false(the abort removes the entry) beforegate.add_permits(1), with a bounded timeout that fails with a clear message rather than hanging. - Add an observable for "a read was aborted" on the test double, mirroring the existing
gate_reads/gate_reads_per_item/gate_createsidiom intesting.rs, and await it.
Either way the release becomes ordered after the abort by construction, and the 50 ms sleep goes.
Residual risk worth stating in the fix: the CLOSE's handler runs in a spawned task (relay.rs spawns each client message independently), so a wait on server-side state is the only ordering that does not depend on scheduling. That is also the mechanism behind #958, which is a separate pre-existing defect and not this test's problem.
Found by the Greptile review on #962 (P2). Recorded rather than fixed there, per the rule that a bot finding which is not a showstopper becomes its own issue instead of blocking the merge that revealed it.
- 主要語言
- TypeScript
- 星號
- 829
- 分支
- 234
- 平均合併
- 17 小時 6 分鐘
- 30 天內合併 PR
- 92
環境準備
- 提供 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
cameri/nostream 的其他 Issue
-
factory rewrite rust
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 1 天內回覆
-
factory rewrite rust
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
test: user-subscription specs fail outside UTC, so the pre-commit hook cannot pass可能已有人在做 @tejasvasingh2004 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
bug factory rewrite rust
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
bug factory rewrite rust
難度 2/5 1-3 小時 新手友好度 84/100
維護者通常 1 天內回覆
相似的 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 68/100
outline/outline#14348 · 1 則留言 ·
維護者通常 1 天內回覆
-
bug needs-triage
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 1 天內回覆
-
[Bug]: Agent import retains quotes in .env API keys followed by inline comments可能已有人在做 @yxr-2025 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 82/100
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 76/100
awslabs/visual-asset-management-system#804 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 68/100
dsh-market/dsh-market#1027 · 1 則留言 ·
維護者通常 1 天內回覆