From 2504aea85f07403708cf443fef2f9a3b909b4133 Mon Sep 17 00:00:00 2001 From: simoleo89 Date: Sun, 24 May 2026 20:43:50 +0200 Subject: [PATCH] fix(room): guard RoomPreviewer.updatePreviewModel against null _planeParser After dispose() nulls out the internal _planeParser / _backgroundSprite refs, any further updatePreviewModel call crashed with 'this._planeParser is null'. React 19 StrictMode in dev double-mounts effects (setup, cleanup, setup again), which can briefly leave a consumer holding a stale reference to a disposed previewer between the two setup runs. Bail silently in that window instead of crashing the editor. --- packages/room/src/RoomPreviewer.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/room/src/RoomPreviewer.ts b/packages/room/src/RoomPreviewer.ts index 53b7537..67e9677 100644 --- a/packages/room/src/RoomPreviewer.ts +++ b/packages/room/src/RoomPreviewer.ts @@ -136,6 +136,12 @@ export class RoomPreviewer public updatePreviewModel(model: string, wallHeight: number, scale: boolean = true): void { + // Defensive: dispose() nulls _planeParser, and React 19 + // StrictMode dev double-mount can leave a stale reference + // briefly pointing at a disposed instance. Bail rather + // than crashing with "cannot read property reset of null". + if(!this._planeParser) return; + const parser = new FloorHeightMapMessageParser(); parser.flush();