fix(nodes): guard previewRef in fence tool onGridClick (Sentry EDITOR-BE/CR)#434
Open
anton-pascal wants to merge 1 commit into
Open
fix(nodes): guard previewRef in fence tool onGridClick (Sentry EDITOR-BE/CR)#434anton-pascal wants to merge 1 commit into
anton-pascal wants to merge 1 commit into
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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, theonGridClickhandler setspreviewRef.current.visible = true/= falsewithout a null guard.previewRefis declareduseRef<Mesh>(null!)and is genuinelynulluntil the<mesh ref={previewRef}>mounts. A grid click processed before the preview mesh mounts (or during an unmount race) dereferencesnulland throws.The sibling
onGridMovehandler already guards correctly withif (!(cursorRef.current && previewRef.current)) return.Fix
Add an early guard at the top of the
onGridClickcallback, mirroring the existingonGridMovepattern:Minimal and surgical — no other behavior changes.
Testing
Isolated
tscon the package surfaces only pre-existing, unrelated peer-dependency errors (e.g.@pascal-app/viewerexports) that exist onmainindependent 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) returnat the start of the fence tool’sonGridClickhandler so grid clicks are ignored until the preview mesh ref is attached.This aligns
onGridClickwithonGridMove, which already bails whenpreviewRefis unset, and prevents production crashes from settingvisibleon 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.