Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

web: second Firefox tab never connects to /api/event - Cache-Control: no-cache lets Firefox's HTTP cache block concurrent SSE requests

未关闭 适合新手
#55,369 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript
领域
backend, frontend

调研方向

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 内容生成。

描述

reproduced
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/event URL 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):

  1. Server: send Cache-Control: no-store (e.g. no-store, no-transform) for /api/event (and other SSE endpoints) in packages/opencode/src/server/routes/instance/httpapi/handlers/event.ts. Event streams should never be stored.
  2. 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
  1. opencode serve, open the web UI in Firefox.
  2. Open the same server/project in a second Firefox tab.
  3. The second tab never receives live events; DevTools > Network shows /api/event requests piling up without status or timings.
  4. 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

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

anomalyco/opencode 的其他 Issue

查看 anomalyco/opencode 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。