fix(canvas): bypass localStoreService singleton — create store directly in effect to eliminate disposed-store reuse
Some checks failed
app-ci-deploy / test-build-deploy (push) Has been cancelled

This commit is contained in:
CC Worker 2026-06-01 06:16:07 +00:00
parent 6cba932146
commit 9a7cc86a75

View File

@ -6,7 +6,8 @@ import {
useTldrawUser,
DEFAULT_SUPPORT_VIDEO_TYPES,
DEFAULT_SUPPORTED_IMAGE_TYPES,
TLStore
TLStore,
createTLStore,
} from '@tldraw/tldraw';
import { useTLDraw } from '../../contexts/TLDrawContext';
import { useAuth } from '../../contexts/AuthContext';
@ -93,10 +94,11 @@ export default function SinglePlayerPage() {
const run = async () => {
try {
setCanvasPhase('store-init');
const newStore = localStoreService.getStore({
// Create a fresh store directly — bypassing singleton to avoid disposed-store reuse issues
const newStore = createTLStore({
schema: customSchema,
shapeUtils: allShapeUtils,
bindingUtils: allBindingUtils
bindingUtils: allBindingUtils,
});
const snapSvc = new NavigationSnapshotService(newStore, editorRef.current || undefined);
@ -154,7 +156,6 @@ export default function SinglePlayerPage() {
snapshotServiceRef.current = null;
storeRef.current?.dispose();
storeRef.current = null;
localStoreService.clearStore(); // reset singleton so next getStore() creates a fresh store
setStoreReady(false);
setCanvasPhase('idle');
};