Skip to content

fix(nodes): guard previewRef in fence tool onGridClick (Sentry EDITOR-BE/CR)#434

Open
anton-pascal wants to merge 1 commit into
mainfrom
fix/sentry-EDITOR-BE
Open

fix(nodes): guard previewRef in fence tool onGridClick (Sentry EDITOR-BE/CR)#434
anton-pascal wants to merge 1 commit into
mainfrom
fix/sentry-EDITOR-BE

Conversation

@anton-pascal

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

Copy link
Copy Markdown
Contributor

Summary

Fixes a production null-deref crash in the fence tool.

Sentry: MONOREPO-EDITOR-BE / EDITOR-CR
Error: TypeError: Cannot set properties of null (setting 'visible')
Where: editor.pascal.app/editor/:projectId

Root cause

In packages/nodes/src/fence/tool.tsx, the onGridClick handler sets previewRef.current.visible = true / = false without a null guard. previewRef is declared useRef<Mesh>(null!) and is genuinely null until the <mesh ref={previewRef}> mounts. A grid click processed before the preview mesh mounts (or during an unmount race) dereferences null and throws.

The sibling onGridMove handler already guards correctly with if (!(cursorRef.current && previewRef.current)) return.

Fix

Add an early guard at the top of the onGridClick callback, mirroring the existing onGridMove pattern:

const onGridClick = (event: GridEvent) => {
  if (!previewRef.current) return
  ...
}

Minimal and surgical — no other behavior changes.

Testing

Isolated tsc on the package surfaces only pre-existing, unrelated peer-dependency errors (e.g. @pascal-app/viewer exports) that exist on main independent of this change; nothing new is introduced by the one-line guard.


Note

Low Risk
Single defensive null check in editor fence drafting; no auth, data, or behavior change when the preview mesh is mounted.

Overview
Adds an early if (!previewRef.current) return at the start of the fence tool’s onGridClick handler so grid clicks are ignored until the preview mesh ref is attached.

This aligns onGridClick with onGridMove, which already bails when previewRef is unset, and prevents production crashes from setting visible on a null ref when a click races mount/unmount.

Reviewed by Cursor Bugbot for commit 3e1b830. Bugbot is set up for automated code reviews on this repo. Configure here.

@mintlify

mintlify Bot commented Jun 21, 2026

Copy link
Copy Markdown

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

Project Status Preview Updated (UTC)
pascal 🔴 Failed Jun 21, 2026, 4:07 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