Skip to content

Commit dc72447

Browse files
committed
fix(opencode): clean up SSE heartbeat on server-initiated stream close
clearInterval(heartbeat) and unsub() only run inside stream.onAbort(), which Hono only fires on client disconnect. When the server closes the stream on InstanceDisposed via stream.close(), the interval and bus subscription leak. Add cleanup before stream.close() in the InstanceDisposed handler. Both calls are idempotent so the onAbort fallback for normal client disconnects still works.
1 parent ca331e5 commit dc72447

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

packages/opencode/src/server/server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,8 @@ export namespace Server {
515515
data: JSON.stringify(event),
516516
})
517517
if (event.type === Bus.InstanceDisposed.type) {
518+
clearInterval(heartbeat)
519+
unsub()
518520
stream.close()
519521
}
520522
})

0 commit comments

Comments
 (0)