web: second Firefox tab never connects to /api/event - Cache-Control: no-cache lets Firefox's HTTP cache block concurrent SSE requests
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 72/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
调研方向
Cache-Control 响应头(用于 /api/event)在 packages/opencode/src/server/routes/instance/httpapi/handlers/event.ts 中设置,网页客户端通过 window.fetch 打开该流。先阅读处理器的响应头,然后找到网页 UI 发起 event-stream fetch 的位置。当流响应为 no-store(或客户端 fetch 使用 cache: "no-store"),并且第二个 Firefox 标签页能连接到 /api/event 而不卡住时,即完成。
由索引模型根据 Issue 内容生成。
描述
Description
In Firefox (also Firefox-based browsers such as Zen), the web UI's live event stream hangs as soon as the same opencode server is open in a second tab. The banner/loading state never clears until the other tab is closed.
GET /api/event is answered with Cache-Control: no-cache, no-transform. no-cache still allows storing, so Firefox writes the response into its HTTP cache. A concurrent request for the same URL then waits for that cache entry to finish being written - which never happens for an endless SSE stream. The second tab's /api/event requests are queued inside the browser forever:
- DevTools shows them with no status, 0 B and "No timings for request" - they are never sent.
- The server never sees them (nothing in the opencode log, no connection attempt).
- The web client aborts each attempt after its 2 s connect deadline and retries, so the queue just grows.
- Other requests to the same host at the same moment (e.g.
/api/session/active) succeed instantly over the same HTTP/2 connection, so this is not a connection or stream limit - only the repeated/api/eventURL is blocked. - Closing the other tab makes the stream connect immediately.
Server responses confirmed from opencode serve v2.0.23:
HTTP/1.1 200 OK
cache-control: no-cache, no-transform
x-accel-buffering: no
content-type: text/event-stream
Transfer-Encoding: chunked
Suggested fix
Either (or both):
- Server: send
Cache-Control: no-store(e.g.no-store, no-transform) for/api/event(and other SSE endpoints) inpackages/opencode/src/server/routes/instance/httpapi/handlers/event.ts. Event streams should never be stored. - Client: issue the event-stream fetch with
cache: "no-store", which bypasses the HTTP cache entirely.
We worked around it by wrapping window.fetch in the web UI and re-issuing /api/event as new Request(request, { headers, cache: "no-store" }).
Steps to reproduce
opencode serve, open the web UI in Firefox.- Open the same server/project in a second Firefox tab.
- The second tab never receives live events; DevTools > Network shows
/api/eventrequests piling up without status or timings. - Close the first tab - the second connects immediately.
Related
#48771, #53498, #51857 describe stalled/never-connecting event streams with other causes; this is a further, browser-side cause with the same symptom.
OpenCode version
2.0.23
Operating System
macOS (Firefox 157 / Zen)
- 主要语言
- TypeScript
- 星标
- 213k
- 派生
- 28.4k
- 平均合并
- 8 小时 51 分钟
- 30 天内合并 PR
- 289
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
anomalyco/opencode 的其他 Issue
-
reproduced
难度 2/5 1-3 小时 新手友好度 66/100
anomalyco/opencode#55351 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 1/5 1-3 小时 新手友好度 72/100
anomalyco/opencode#55285 · 2 条评论 ·
维护者通常 1 天内回复
-
opencode on clean macos zsh .export path not working because it append and it fails because no ~/.zshrc file可能已有人在做 @fihaaade 于 1 天前认领。 未关闭reproduced
难度 2/5 1-3 小时 新手友好度 75/100
anomalyco/opencode#55068 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
anomalyco/opencode#54919 · 1 条评论 ·
维护者通常 1 天内回复
-
triaging
难度 2/5 1-3 小时 新手友好度 73/100
anomalyco/opencode#54887 · 1 条评论 ·
维护者通常 1 天内回复
查看 anomalyco/opencode 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
apollographql/apollo-client#13493 ·
维护者通常 1 天内回复
-
Custom hosts written as trailing-dot FQDNs (`host.local.`) aren't detected as local backends可能已有人在做 @roboomp 今天认领。 未关闭bug prio:p2 providers triaged
难度 2/5 1-3 小时 新手友好度 82/100
can1357/oh-my-pi#15798 · 3 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
code-yeongyu/oh-my-openagent#10172 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
PDFCraftTool/pdfcraft#189 ·
-
Add the Yahoo chart API duplicate last-day row (yfinance#573) to incidents.md (about 1 hour)可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭data docs good first issue
难度 1/5 1 小时以内 新手友好度 80/100
pacocartones/market-data-sanity-checker#160 ·
维护者通常 1 天内回复