Skip to content

fix(server): start thread live subscribe immediately - #8420

Open
Adolanium wants to merge 1 commit into
pingdotgg:mainfrom
Adolanium:fix/subscribe-thread-live-buffer-start
Open

fix(server): start thread live subscribe immediately#8420
Adolanium wants to merge 1 commit into
pingdotgg:mainfrom
Adolanium:fix/subscribe-thread-live-buffer-start

Conversation

@Adolanium

@Adolanium Adolanium commented Aug 27, 2026

Copy link
Copy Markdown

What Changed

subscribeThread now starts its live event buffer fork with startImmediately: true, the same as subscribeShell.

The test that covers events published while the thread snapshot loads no longer waits 25ms before publishing. That wait let the late fork still catch the event, so a lost event would not fail the test. It now publishes during the snapshot load.

Why

The comment on subscribeThread already says live delivery must attach before the snapshot loads, or an event can be lost. Effect 4 runs forkScoped on a later tick unless you pass startImmediately. Shell already passed it. Thread did not.

A message or activity that lands in that gap never reaches the client. Reconnect cannot put it back if catch-up already used a snapshot taken before that event.

UI Changes

None.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes (N/A)
  • I included a video for animation/interaction changes (N/A)

Note

Low Risk
Small, targeted WebSocket subscription fix aligned with existing shell behavior; test change only tightens coverage.

Overview
Thread WebSocket subscriptions now fork the live event buffer with startImmediately: true, matching subscribeShell. Under Effect 4, forkScoped runs on a later tick by default, so events published while the thread snapshot or catch-up replay was still loading could miss the live stream and never reach the client.

The integration test for “message sent during snapshot load” publishes the event immediately during snapshot fetch instead of sleeping 25ms first, so a regression in that ordering would fail instead of being masked by delayed scheduling.

Reviewed by Cursor Bugbot for commit 70be50a. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Start WebSocket live stream subscription fiber immediately in makeWsRpcLayer

Passes { startImmediately: true } to the Effect.forkScoped call in ws.ts so the live delivery fiber starts on the current tick, before snapshot or replay reads begin. This closes a window where events published during snapshot loading could be lost. The test stub in server.test.ts removes a 25 ms sleep and now publishes a live event during snapshot load to exercise this timing.

  • Behavioral Change: the live subscription fiber starts synchronously rather than on the next tick; the test stub no longer delays event publication, so tests that relied on the 25 ms window may need updating.

Macroscope summarized 70be50a.

subscribeShell already starts its live buffer fork now. subscribeThread
did not. Effect 4 runs forkScoped on a later tick unless startImmediately
is set, so an event published while the thread snapshot loads can miss
the buffer.

The existing buffer test published after a 25ms sleep, which hid that
gap. It now publishes during the snapshot load, same as the shell test.
@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 94a6b111-536d-480e-991f-3810d0ac26f1

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Aug 27, 2026
@macroscopeapp

macroscopeapp Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 70be50a

Macroscope's review found this PR approvable — This is a focused server bug fix that starts the existing thread live-event buffer before snapshot or replay work, preventing events from being missed during that window. The accompanying test removes an artificial delay and directly verifies delivery during snapshot loading.

You can add or adjust custom eligibility rules. Learn more.

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

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant