fix: remove context reaper to prevent background tabs from going stale
Some checks failed
CI / Build and Test (push) Failing after 37s
CI / Build and Test (pull_request) Failing after 36s

Background windows stopped updating because the reaper suspended contexts
after ContextSuspendAfter and fully reaped them after ContextTTL. Suspended
contexts had to re-run the page init function from scratch on reconnect,
losing the live-updating experience.

Contexts now live until the browser tab closes (beforeunload beacon) or
the server shuts down. The context map grows indefinitely — no background
reaper.

Removes: startReaper, reapOrphanedContexts, suspend/resume logic,
ContextSuspendAfter/ContextTTL config fields, lastSeenAt/suspended
context fields, and all associated tests.
This commit is contained in:
Ryan Hamamura
2026-02-20 08:48:21 -10:00
parent c0f4782f2b
commit 4191302cb8
6 changed files with 1 additions and 274 deletions

View File

@@ -42,8 +42,6 @@ type Context struct {
createdAt time.Time
sseConnected atomic.Bool
sseDisconnectedAt atomic.Pointer[time.Time]
lastSeenAt atomic.Pointer[time.Time]
suspended atomic.Bool
}
// View defines the UI rendered by this context.
@@ -444,13 +442,6 @@ func (c *Context) resetPageState() {
c.mu.Unlock()
}
// suspend frees page-scoped resources while keeping the context shell alive
// in the registry for seamless re-init on reconnect.
func (c *Context) suspend() {
c.resetPageState()
c.suspended.Store(true)
}
// Navigate performs an SPA navigation to the given path. It resets page state,
// runs the target page's init function (with middleware), and pushes the new
// view over the existing SSE connection with a view transition animation.