Skip to content

[Fix] Code-editor null guards for Sentry tier 2 errors#2012

Merged
kpal81xd merged 4 commits intomainfrom
fix/sentry-browser-live-tier2
Apr 15, 2026
Merged

[Fix] Code-editor null guards for Sentry tier 2 errors#2012
kpal81xd merged 4 commits intomainfrom
fix/sentry-browser-live-tier2

Conversation

@kpal81xd
Copy link
Copy Markdown
Contributor

What's Changed

Four fixes for Tier 2 Sentry issues in the browser_live environment, all in the code-editor:

  • PLAY-CANVAS-G3DM (7 events): Guard doc.on('load') handler in documents-load.ts against null doc.type — the collab server's checkpoint cleanup can null document data in MongoDB, causing ShareDB to deliver snapshots with type=null. The guard pattern already exists in sharedb.ts:398 and userdata-realtime.ts:36 but was missing here.
  • PLAY-CANVAS-G3EA (4 events): Filter out undefined results from assets:getByVirtualPath before passing to loadDocument() during ESM dependency resolution — unresolved import paths return undefined which crashes on .get('id').
  • PLAY-CANVAS-G3CG (6 events): Replace two-pass check-then-map path resolution with a single-pass loop in monaco/document.ts — eliminates a TOCTOU race where an asset could be removed between the some() check and the subsequent map(a => a.get('name')).
  • PLAY-CANVAS-G3E0 (1 event): Add !item.destroyed guard in files:select method — matches the pattern already used in the documents:close handler in the same file. Prevents classList access on a destroyed TreeViewItem during asset deletion races.

Checks

kpal81xd and others added 4 commits April 15, 2026 13:05
When the collab server's checkpoint cleanup nulls a document's _data
in MongoDB, ShareDB delivers a snapshot with type=null. The load
handler in documents-load.ts was missing the guard already present in
sharedb.ts and userdata-realtime.ts, causing downstream consumers to
crash on null doc.data.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…G3EA)

assets:getByVirtualPath can return undefined for import paths that
don't resolve to a loaded asset. Filter these out before passing to
loadDocument() which expects a valid Observer with .get().

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…S-G3CG)

Replace the two-pass check-then-map pattern with a single-pass loop
that bails on the first missing asset. The previous pattern had a
window between the some() check and the subsequent map() where an
asset could be removed by a concurrent event.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When an asset is deleted, the TreeViewItem is destroyed but remains
in the idToItem map briefly. A racing files:select call (from tab
close) could set selected on the destroyed item, accessing classList
on a null DOM element. Add the same !item.destroyed guard already
used in the documents:close handler.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@kpal81xd kpal81xd self-assigned this Apr 15, 2026
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
editor Ready Ready Preview, Comment Apr 15, 2026 0:09am

Request Review

@kpal81xd kpal81xd merged commit 7cf18e1 into main Apr 15, 2026
7 checks passed
@kpal81xd kpal81xd deleted the fix/sentry-browser-live-tier2 branch April 15, 2026 12:50
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