Skip to content

Commit 6248153

Browse files
ra3orbladeclaude
andcommitted
fix: defer chat badge autorun to avoid module-init TDZ crash
The badge autorun fired synchronously inside the ChatStore constructor, which runs at module load. Auto-imported globals used in setBadge -> getTotalCounters (U.Space) were not yet initialized in some module evaluation orders, causing a "Cannot access 'tt' before initialization" ReferenceError from MobX. Schedule the autorun via queueMicrotask so all top-level module evaluation finishes first, while still binding before any user interaction. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 48db477 commit 6248153

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/ts/store/chat.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ChatStore {
2525
discussionParentMapDelete: action,
2626
});
2727

28-
autorun(() => this.setBadge());
28+
queueMicrotask(() => autorun(() => this.setBadge()));
2929
};
3030

3131
/**

0 commit comments

Comments
 (0)