Skip to content

fix: resolve Sentry errors BD, BE, 9E#323

Merged
Aymericr merged 1 commit into
mainfrom
fix/sentry-BD-BE
Jun 3, 2026
Merged

fix: resolve Sentry errors BD, BE, 9E#323
Aymericr merged 1 commit into
mainfrom
fix/sentry-BD-BE

Conversation

@anton-pascal

@anton-pascal anton-pascal commented May 21, 2026

Copy link
Copy Markdown
Contributor

Fixes Sentry errors where cursorGroupRef.current and wallPreviewRef.current are read as null during placement-coordinator and wall-tool event handlers.

Sentry impact (live as of 2026-05-27 04:00 UTC nightly triage):

  • MONOREPO-EDITOR-BCCannot read properties of null (reading 'rotation')53,478 events since 2026-05-20
  • MONOREPO-EDITOR-BD — same family — 403 events since 2026-05-20
  • MONOREPO-EDITOR-BECannot set properties of null (setting 'visible') in wall-tool — handled by the wall/tool.tsx hunk
  • MONOREPO-EDITOR-9E — same family

Root cause. mitt dispatches synchronously by mapping over a snapshot of the listener set, so a handler can still run after the cleanup function has called emitter.off(...) if the emit is already in flight. By that point React has already unmounted the <group ref={cursorGroupRef}> / <mesh ref={wallPreviewRef}>, so *.current is null and any .rotation / .visible write throws.

Fix. Defensive if (!ref.current) return early-return at the top of every grid/wall/item/ceiling on* handler, plus optional-chain on the two read sites that need a fallback (cursorGroupRef.current?.rotation.y ?? 0).

Two files, +31 / -6 lines:

  • packages/editor/src/components/tools/item/use-placement-coordinator.tsx
  • packages/nodes/src/wall/tool.tsx

Rebased onto current main 2026-05-27 04:30 UTC; wall/tool.tsx conflict (HEAD added a double-click guard, this branch added the null-ref guard) resolved to keep both. bun run check clean on the touched files.

The single failing check is the cosmetic Mintlify docs preview, unrelated to this code.

🤖 Authored by Anton (Pascal AI assistant). Diagnosis written up in memory/sentry-triage/2026-05-27.md.

@mintlify

mintlify Bot commented May 21, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
pascal 🔴 Failed May 21, 2026, 4:08 AM

💡 Tip: Enable Workflows to automatically generate PRs for you.

Aymericr pushed a commit that referenced this pull request Jun 3, 2026
Adds the missing `if (!cursorGroupRef.current) return` guard to onShelfMove. mitt listeners are registered for the tool's whole lifetime, so a shelf event can fire before the cursor group mounts or after teardown, leaving the ref null and throwing on `cursorGroupRef.current.rotation.y`.

Partial fix for the EDITOR-BC family: the other placement handlers (onGridMove/onWallMove/onItemMove/onCeilingMove and the keyboard/cancel paths) share the same null-ref exposure and still need the broader, correctly-scoped guard — tracked separately (PR #323 attempts this but needs rework).
Guard every cursorGroupRef.current dereference against the null window
where mitt listeners are live but the <group> is unmounted (mount/teardown
race) — the EDITOR-BC/BD family. getContext() falls back to the draft's
rotation so the validation/revalidate path (Shift keys, onKeyUp) is safe;
only the cursor writes are guarded, so cancel, Shift reset, leave-state
cleanup and transition state still run unconditionally. Also guards
wallPreviewRef in WallTool.stopDrafting() (the double-click/cancel path).

Reimplements #323 against current main without its over-broad handler
guards that silently dropped Escape-cancel and Shift state.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Aymericr Aymericr force-pushed the fix/sentry-BD-BE branch from eff414b to 353fc0a Compare June 3, 2026 19:54
@Aymericr Aymericr merged commit cefcb01 into main Jun 3, 2026
1 check failed
@Aymericr Aymericr deleted the fix/sentry-BD-BE branch June 3, 2026 19:54
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