Skip to content

fix(web): stop settings subscribers from hanging startup - #196

Merged
nullStack65 merged 1 commit into
release/native-0.1.10from
fix/clo-1167-settings-startup
Nov 24, 2026
Merged

nullStack65 merged 1 commit into
release/native-0.1.10from
fix/clo-1167-settings-startup

Conversation

@nullStack65

@nullStack65 nullStack65 commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

What broke

Since the desktop release built from c363c6e (release/native-0.1.10), T3 Code freezes on startup and never finishes loading. On the founder laptop the renderer's memory climbs to 2–4 GB within about a minute of the page loading (the old release 3ad1bfd peaked around 0.6 GB on the same data). The 7 GB machine starts swapping, and the renderer crashes with exit code 133 (V8 out of memory), then reloads and does it again. Owning ticket: the T3 desktop startup failure (CLO-1167).

Root cause

viewerFounderAtom (added in #157, "show who spoke and keep each founder's place") subscribes to client settings and calls get.refreshSelf() from the listener. Refreshing disposes the atom's lifetime, which unsubscribes the old listener, and the rebuild subscribes a new one. Both settings emitters iterated their live Set, and Set iteration visits entries appended during the loop. So when hydration calls the settings setter, the emitter sees each new listener, refreshes again, and keeps going forever.

Evidence from the live installed app: with the debugger attached to the busy renderer, 10 of 10 pause samples landed in this loop:

emitClientSettingsChange (useSettings)  ->  listener -> refreshSelf -> invalidate -> propagate -> build
  -> viewerFounderAtom build -> subscribeClientSettings / subscribeClientSettingsHydration (Set.add)

Fix

Both emitters now loop over a snapshot of the listeners taken when the notification starts, and skip any listener removed during the loop. Effect atom lifetimes already no-op refreshSelf/setSelf after disposal, so calling a stale listener would be harmless anyway; the has check just avoids the extra call.

Verification

  • apps/web/src/hooks/useSettings.test.ts: 14 of 14 pass (re-run independently on this head). Both new regressions failed before the patch.
  • Still to do after merge: release build, install on the laptop, and a desktop launch that loads fully.

Deploy: fleet

🤖 Generated with Claude Code

Model: GPT-6
Task: CLO-1167 desktop startup repair
Agent: Codex
Lane: codex
@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@nullStack65

Copy link
Copy Markdown
Owner Author

Independent review (Claude Code), head 1c99e35d949b2c2adcb3d3e598087a258096a55c

I reached the same root cause separately, from the installed app (c363c6e) rather than from this patch. I paused the busy renderer over the DevTools protocol, and all 10 stacks landed in emitClientSettingsChange → viewerFounderAtom listener → refreshSelf → rebuild → subscribeClientSettings/subscribeClientSettingsHydration adding a new listener to the Set being iterated. The renderer's main thread never answered Runtime.getHeapUsage and grew until the watchdog stopped it.

What I checked in the diff:

  • Snapshot iteration plus the has guard stops the loop in both emitters. Both emitters had the same faulty pattern, and both are fixed.
  • Calling a listener removed mid-loop would be harmless anyway: effect's Lifetime.refreshSelf/setSelf return early once disposed (AtomRegistry.ts). The guard just skips the extra work.
  • Other refreshSelf subscribers (timers, deadlineStore) don't re-subscribe to the same live Set synchronously, so they're out of scope.
  • vp test run --project unit src/hooks/useSettings.test.ts: 14/14 pass on this head.

No findings. Ready to merge once ARC CI is green.

@nullStack65
nullStack65 merged commit f0ee13d into release/native-0.1.10 Nov 24, 2026
6 of 11 checks passed
@nullStack65
nullStack65 deleted the fix/clo-1167-settings-startup branch November 24, 2026 03:07
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.

2 participants