Skip to content

fix(server): preserve directory events across reloads - #42632

Open
kernel-oops wants to merge 1 commit into
anomalyco:devfrom
kernel-oops:fix/directory-sse-replacement
Open

fix(server): preserve directory events across reloads#42632
kernel-oops wants to merge 1 commit into
anomalyco:devfrom
kernel-oops:fix/directory-sse-replacement

Conversation

@kernel-oops

@kernel-oops kernel-oops commented Aug 14, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #36495

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

A directory-scoped /event stream currently ends when its instance is disposed, even though the subscription is keyed by the stable directory and the replacement instance emits to the same process-wide bus. This keeps the stream open across disposal/recreation while still forwarding server.instance.disposed as an informational event.

The bus subscriptions now live for the actual response-body lifetime and are removed when the client socket closes, avoiding a listener leak.

How did you verify your code works?

Added regression tests showing that one connection receives the disposal event and later events from the replacement instance, and that a real Node/Bun socket disconnect returns the global listener count to baseline. The focused tests pass (5 tests), as does the OpenCode typecheck.

Screenshots / recordings

N/A — server SSE behavior only.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Aug 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

One potentially related PR found:

#39349: fix(app): recover from a silently dead event stream
#39349

This PR may be related because it also addresses event stream issues in the context of the app consuming server events. Your current PR (42632) fixes the server side by keeping directory event streams alive across reloads, while #39349 appears to handle client-side recovery when event streams become unresponsive. They complement each other in improving event stream reliability.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Aug 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GET /event?directory= stream is killed by PATCH /config (instance dispose), starving directory-scoped subscribers

1 participant