Skip to content

fix(editor): guard onShelfMove against null cursorGroupRef (Sentry EDITOR-BC, 53k+ events)#342

Open
anton-pascal wants to merge 1 commit into
mainfrom
fix/sentry-editor-BC
Open

fix(editor): guard onShelfMove against null cursorGroupRef (Sentry EDITOR-BC, 53k+ events)#342
anton-pascal wants to merge 1 commit into
mainfrom
fix/sentry-editor-BC

Conversation

@anton-pascal
Copy link
Copy Markdown
Contributor

Summary

Adds the missing if (!cursorGroupRef.current) return guard at the top of onShelfMove in packages/editor/src/components/tools/item/use-placement-coordinator.tsx.

Sentry signal

Field Value
Short ID MONOREPO-EDITOR-BC
Error TypeError: Cannot read properties of null (reading 'rotation')
Environment vercel-production
First seen 2026-05-20 01:42 UTC
Last seen 2026-05-27 18:34 UTC
Events 53,528
Family Same root cause as EDITOR-BG (2,830 events) and EDITOR-BH (378 events) — all hit the same handler from the same null deref

Stack frames:

node_modules/.bun/mitt@3.0.1/.../mitt/src/index.ts: in map
editor/packages/editor/src/components/tools/item/use-placement-coordinator.tsx: in p (or t / E — minified)

Root cause

Every other surface-move handler in this file (onGridMove, onWallMove, onCeilingMove, onItemMove) already short-circuits when cursorGroupRef.current is null. onShelfMove writes cursorGroupRef.current.position.set(...) and cursorGroupRef.current.rotation.y = ... without that guard, so when a shelf-surface hover stream from the mitt emitter races with cursor unmount (or fires before the <group ref> attaches), the rotation write throws.

That gap was missed when #323 added guards to BD/BE/9E.

Why it's high-confidence

  • Pattern parity: the guard already exists in 6 sibling handlers in the same file. This change brings onShelfMove into line with them.
  • Behavior unchanged when mounted: cursorGroupRef.current is non-null in normal interaction; the early return only fires during unmount/teardown races, which is exactly when the throw was happening.
  • No type or lint surface changes.

Followups (separate)

  • EDITOR-BG / EDITOR-BH have stack frames pointing at use-placement-coordinator.tsx lines that are the guarded handlers in fix: resolve Sentry errors BD, BE, 9E #323. Worth re-checking after this lands and fix: resolve Sentry errors BD, BE, 9E #323 lands; the 2,830 + 378 events may largely come from the same shelf path or a tiny remaining gap.
  • EDITOR-BR (/api/mcp ZodError, ~348 events) is unrelated, blocked on schema migration.

🤖 Detected and fixed by the nightly Sentry triage agent. Aymeric — never auto-merging.

Every other surface-move handler in use-placement-coordinator
(onGridMove, onWallMove, onCeilingMove, onItemMove) already
short-circuits when cursorGroupRef.current is null. onShelfMove
was missed in PR #323 and went on to throw

  TypeError: Cannot read properties of null (reading 'rotation')

53,528 times in vercel-production between 2026-05-20 and 2026-05-27,
all firing from the mitt event-emitter dispatch loop while a shelf
hover stream raced with cursor unmount.

The fix is a one-line guard matching the existing pattern; behavior
is unchanged when cursorGroupRef is mounted.
@mintlify
Copy link
Copy Markdown

mintlify Bot commented May 28, 2026

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

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

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

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.

1 participant