mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-19 23:16:21 +00:00
Enable <StrictMode> + make App.tsx renderer init idempotent
App.tsx's prepare() useEffect ran four .init() calls (SessionDataManager, RoomSessionManager, RoomEngine, Communication) without any guard, plus an immediate heartbeat ping and a legacy authentication track. Under StrictMode dev double-invoke, those fire twice — risking duplicate session/communication state. - Gate the four .init() chain behind gameInitPromiseRef: both the first and the simulated second invocation await the same promise. - Gate the legacy track + immediate heartbeat behind bootstrapDoneRef. - Heartbeat and remember-rotate intervals were already idempotent (clearInterval before setInterval); ticker registration was already guarded by tickersStartedRef; renderer/warmup were already gated by rendererPromiseRef/warmupPromiseRef. No change needed there. Wrap <App /> in <StrictMode> in src/index.tsx now that the renderer init path is double-invoke safe. https://claude.ai/code/session_01GrR87LAqnAEyKG2ZbmQt5Q
This commit is contained in:
+14
-12
@@ -1,4 +1,4 @@
|
||||
import { Suspense } from 'react';
|
||||
import { StrictMode, Suspense } from 'react';
|
||||
import { createRoot } from 'react-dom/client';
|
||||
import { ErrorBoundary } from 'react-error-boundary';
|
||||
import { App } from './App';
|
||||
@@ -44,15 +44,17 @@ import './css/toolbar/ToolBar.css';
|
||||
import './css/widgets/FurnitureWidgets.css';
|
||||
|
||||
createRoot(document.getElementById('root')).render(
|
||||
<ErrorBoundary
|
||||
fallbackRender={ ({ error }) => (
|
||||
<LoadingView
|
||||
isError={ true }
|
||||
message={ `Something went wrong.\n${ (error as Error)?.message ?? 'Unknown error' }` }
|
||||
homeUrl={ window.location.origin + '/' } />
|
||||
) }>
|
||||
<Suspense fallback={ <LoadingView message="Loading…" /> }>
|
||||
<App />
|
||||
</Suspense>
|
||||
</ErrorBoundary>
|
||||
<StrictMode>
|
||||
<ErrorBoundary
|
||||
fallbackRender={ ({ error }) => (
|
||||
<LoadingView
|
||||
isError={ true }
|
||||
message={ `Something went wrong.\n${ (error as Error)?.message ?? 'Unknown error' }` }
|
||||
homeUrl={ window.location.origin + '/' } />
|
||||
) }>
|
||||
<Suspense fallback={ <LoadingView message="Loading…" /> }>
|
||||
<App />
|
||||
</Suspense>
|
||||
</ErrorBoundary>
|
||||
</StrictMode>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user