endpoints: a far-future event panics inside write_lock and poisons it, so every later write returns 500 until restart
维护者通常 1 天内回复
评估
调研方向
Start in aw-server/src/endpoints/bucket.rs, where bucket_events_create and bucket_events_heartbeat call event_range() while holding write_lock. The overflow comes from Event::calculate_endtime() in aw-models/src/event.rs (line 43), which uses plain +. Reproduce with the Rocket local client using a far-future timestamp, then confirm the endpoint returns 400 and that later writes still succeed.
由索引模型根据 Issue 内容生成。
描述
In aw-server/src/endpoints/bucket.rs, both bucket_events_create and bucket_events_heartbeat call event_range() while holding state.write_lock (write_lock.lock().unwrap(), lines ~179 and ~224). event_range() calls Event::calculate_endtime() (aw-models/src/event.rs:43), which adds the duration with a plain +. That addition panics when the result overflows chrono's range.
An event with a far-future timestamp and a valid duration (< 292 years) therefore panics inside the lock and poisons the Mutex. Every later lock().unwrap() then panics too, so all event writes return 500 until the server restarts: every watcher's heartbeats, event creates, single and bulk deletes. The datastore's own range check (event_nanos) would return a clean 400, but it runs after this point.
Repro (Rocket local client, upstream master ea6f09c):
POST /api/0/buckets/aw-watcher-web-firefox/heartbeat?pulsetime=1
{"timestamp":"+262000-01-01T00:00:00Z","duration":9e9,"data":{}}
-> 500 (panic: `DateTime + TimeDelta` overflowed)
POST /api/0/buckets/aw-watcher-web-firefox/heartbeat?pulsetime=1
{"timestamp":"2026-01-01T00:00:00Z","duration":0,"data":{}}
-> 500 (and the same for POST .../events and DELETE .../events/1)
POST .../events with the same far-future event gives the same result. A browser extension can send it too: the default CORS rule admits moz-extension:// origins for aw-watcher-web-* buckets. So one buggy client clock or extension takes data collection down for every watcher, silently, until restart.
Suggested fix
- Compute the range with
checked_add_signedand return 400 before taking the lock. Or validate the event's range first and take the lock after. - Stop the lock from failing permanently, e.g.
lock().unwrap_or_else(PoisonError::into_inner). It guards only ordering and protects no invariant that a panic could break.
Found in a verified review pass over the endpoints. No PR from me yet, because I already have three open from this pass (#869, #870, #871).
- 主要语言
- Rust
- 星标
- 322
- 派生
- 107
- 平均合并
- 2 天 16 小时
- 30 天内合并 PR
- 25
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ActivityWatch/aw-server-rust 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
ActivityWatch/aw-server-rust#883 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 80/100
ActivityWatch/aw-server-rust#872 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
ActivityWatch/aw-server-rust#798 · 1 条评论 ·
维护者通常 1 天内回复
-
query: categorize rules can pin unbounded memory in the regex cache and run past query_timeout可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 4/5 3-5 天 新手友好度 22/100
ActivityWatch/aw-server-rust#893 · 1 条评论 ·
维护者通常 1 天内回复
-
aw-client CLI ignores aw-client.toml host/port可能已有人在做 @TimeToBuildBob 于 1 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 35/100
ActivityWatch/aw-server-rust#888 ·
维护者通常 1 天内回复
查看 ActivityWatch/aw-server-rust 的全部 Issue
相似的 Issue
-
renaming a provider to a taken name fails with a raw sql error可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭area:storage kind:bug priority:p3 ready
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
XLSX files cannot be imported into Adobe InDesign due to missing AppVersion in extended properties未关闭
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
qingjian-team/qingjian#1181 ·
维护者通常 2 天内回复