fix: remove context reaper to prevent background tabs from going stale
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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user