Skip to content

feat(host): every read the host follows over Realtime shares one socket (P1) - #3287

Closed
charleslpan wants to merge 2 commits into
mainfrom
luke/neon-realtime-shared-socket
Closed

charleslpan wants to merge 2 commits into
mainfrom
luke/neon-realtime-shared-socket

Conversation

@charleslpan

@charleslpan charleslpan commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Stack P · Live plumbing, P1 of 4. Rebuilt on main's live-follow.ts (#4072, plus #4172's poll fallback). This PR is now only P1.

  • Every read at one address shares one Realtime client, and the socket closes when its last holder lets go (shareLiveClients).
  • Once any subscription on the shared client goes to error, the next read opens a new client. Neon's guide says a client whose connection failed can't reconnect. The old one closes when its last holder lets go. This fits feat(host): a live read polls while Realtime fails it #4172: its resubscribe opens a fresh client.

The same-user check and the account-inbox and scope-inbox hunks have moved out. The same-user check is now #4228. The scope inbox moves up to #3232. The account inbox stays on the held read (#4074).

Tests: live-follow.test.ts, the shared-client cases.

@vercel

vercel Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
luke-web Ready Ready Preview Oct 20, 2026 9:39pm UTC

Request Review

@luke-agent
luke-agent Bot changed the base branch from main to luke/neon-realtime-scope-inbox October 17, 2026 01:30
@luke-agent luke-agent Bot closed this Oct 17, 2026
@luke-agent luke-agent Bot reopened this Oct 17, 2026
@luke-agent
luke-agent Bot force-pushed the luke/neon-realtime-scope-inbox branch from 0a6e6cd to 35d1920 Compare October 18, 2026 19:21
@luke-agent
luke-agent Bot force-pushed the luke/neon-realtime-shared-socket branch from b9113b0 to 6b39c87 Compare October 18, 2026 19:53
@luke-agent
luke-agent Bot force-pushed the luke/neon-realtime-scope-inbox branch from 35d1920 to ff729c0 Compare October 18, 2026 21:12
@luke-agent
luke-agent Bot force-pushed the luke/neon-realtime-shared-socket branch from 6b39c87 to c64350e Compare October 18, 2026 21:41
@luke-agent
luke-agent Bot force-pushed the luke/neon-realtime-scope-inbox branch from ff729c0 to 7c1c859 Compare October 19, 2026 18:52
@luke-agent
luke-agent Bot force-pushed the luke/neon-realtime-shared-socket branch from c64350e to 9ef7250 Compare October 19, 2026 18:53
@luke-agent
luke-agent Bot force-pushed the luke/neon-realtime-scope-inbox branch from 7c1c859 to 40e92d8 Compare October 20, 2026 00:57
@luke-agent
luke-agent Bot force-pushed the luke/neon-realtime-shared-socket branch from 9ef7250 to 48b281d Compare October 20, 2026 01:15
@luke-agent
luke-agent Bot force-pushed the luke/neon-realtime-scope-inbox branch from a7cb527 to 39ca561 Compare October 20, 2026 01:29
@luke-agent
luke-agent Bot force-pushed the luke/neon-realtime-shared-socket branch from 48b281d to 21e5770 Compare October 20, 2026 01:31
@luke-agent
luke-agent Bot force-pushed the luke/neon-realtime-scope-inbox branch from 39ca561 to 40e1669 Compare October 20, 2026 01:43
@luke-agent
luke-agent Bot force-pushed the luke/neon-realtime-shared-socket branch from 21e5770 to 7bbd164 Compare October 20, 2026 01:44
luke-agent Bot added a commit that referenced this pull request Oct 20, 2026
…another's session is signed out

As #3287's live reads now do, `listLive` sends `?userId=` and answers
`LIVE_SIGNED_OUT` where the service refuses the session as another
account's.

Co-authored-by: luke-agent[bot] <339870089+luke-agent[bot]@users.noreply.github.com>
luke-agent Bot added a commit that referenced this pull request Oct 20, 2026
… for good once signed out

Each seal and renewal of a workspace's issues names the account signed in
as the follow started, as #3287's follows do; a seal or renewal refused as
signed out ends the follow rather than asking again, and a follow that
broke says why in the log before it starts again.

Co-authored-by: luke-agent[bot] <339870089+luke-agent[bot]@users.noreply.github.com>
@luke-agent
luke-agent Bot force-pushed the luke/neon-realtime-scope-inbox branch 2 times, most recently from ff97170 to 9710e65 Compare October 20, 2026 15:50
@luke-agent
luke-agent Bot force-pushed the luke/neon-realtime-shared-socket branch from 1afaa1b to e95f277 Compare October 20, 2026 21:35
@luke-agent
luke-agent Bot changed the base branch from luke/neon-realtime-scope-inbox to main October 20, 2026 21:35
@luke-agent
luke-agent Bot added this pull request to stack #4231 October 20, 2026 21:35
@luke-agent
luke-agent Bot removed this pull request from stack #4231 October 20, 2026 21:46
@luke-agent luke-agent Bot closed this Oct 20, 2026
@luke-agent luke-agent Bot reopened this Oct 20, 2026
@luke-agent luke-agent Bot changed the title feat(host): every read the host follows over Realtime shares one socket feat(host): every read the host follows over Realtime shares one socket (P1) Oct 20, 2026
charleslpan and others added 2 commits October 20, 2026 22:14
Neon's client multiplexes every subscription over one connection, and its
guide says to create one client for the whole app. The host opened one per
followed read, so an account whose Inbox follows many plans held many
sockets. openRealtimeClient now shares one client per address, by handle:
a read's close lets go of its handle, and the socket closes with the last.

Co-authored-by: luke-agent[bot] <339870089+luke-agent[bot]@users.noreply.github.com>
… on it moves to error

Neon's guide: a client whose connection failed cannot reconnect, so a new
one is created before subscribing again. The next read opens a new
client rather than sharing one that may be dead; the old one closes once
its last holder lets go.

Co-authored-by: luke-agent[bot] <339870089+luke-agent[bot]@users.noreply.github.com>
@luke-agent
luke-agent Bot force-pushed the luke/neon-realtime-shared-socket branch from e95f277 to 9589265 Compare October 20, 2026 22:20
@luke-agent

luke-agent Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Closing for now: the developer moved every area onto the central live layer with Neon Realtime off (LUKE_REALTIME, #4267; held polls, #4272), and this change only does something with Realtime on. The branch is kept, so the PR can be reopened and rebased when LUKE_REALTIME goes back on.

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.

1 participant