Repository navigation
Conversation
added 2 commits
September 21, 2026 23:16
- Add max retry limit (10 attempts) to prevent infinite retry loops - Increase backoff range from 250ms-4s to 1s-30s for mobile networks - Add jitter (±20%) to avoid thundering-herd reconnects - Add network awareness: pause retries when offline, resume on online event - Add heartbeat detection (30s interval) to detect dead connections early - Cache connect tokens for 5 minutes to reduce reconnection latency - Invalidate cached token on abnormal close for fresh credentials
Bun 1.3.14 does not emit ServerResponse close when an SSE client disconnects (oven-sh/bun#14697). This causes @effect/platform-node to keep the request fiber alive, writing heartbeats to a dead socket and pinning one CPU core at 100%. Bridge the gap by destroying the response from the request aborted event on Bun, which triggers the missing close event and allows Effect to release the SSE stream. Closes anomalyco#36311
Contributor
|
The following comment was made by an LLM, it may be inaccurate: |
3 of 6 tasks
Author
|
Superseded by #51835 on �2. dev is not where merges land (recent merges are overwhelmingly into |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #36311
Type of change
What does this PR do?
On Bun 1.3.14,
node:httpdoes not emitServerResponse"close" when an SSE client disconnects (oven-sh/bun#14697).@effect/platform-nodewaits for that event to interrupt the request fiber, so when a TUI drops its/api/eventSSE connection the server-side event stream never gets released. It keeps writing heartbeats into a dead socket, which pins one CPU core at 100% and makes the server completely unresponsive (health checks, new connections — everything hangs).The fix is the bridge suggested in the issue: on Bun only, destroy the response from the request "aborted" event. This makes Bun emit the missing "close" so Effect can interrupt the stream and release its event subscription.
The change is a single guard in
packages/opencode/src/server/server.tsat thecreateServer()call site, gated byprocess.versions.bun.How did you verify your code works?
req-aborted+req-closebut NOTres-closewhen SSE client disconnects (from issue's reduced reproduction)res-close+req-closenormally (bridge is Bun-only viaprocess.versions.buncheck)req.once("aborted", () => res.destroy())) is the exact mitigation recommended in the issue and already implemented in the upstream PR fix(server): release SSE streams when a Bun client disconnects #44341writableEnded/destroyedguards prevent destroying already-finished responsesScreenshots / recordings
N/A — server-side performance fix, no UI changes.
Checklist