Skip to content

[FIX] Guard userdata submitOp when document does not exist#2008

Merged
kpal81xd merged 1 commit intomainfrom
fix/guard-userdata-submit-on-missing-document
Apr 14, 2026
Merged

[FIX] Guard userdata submitOp when document does not exist#2008
kpal81xd merged 1 commit intomainfrom
fix/guard-userdata-submit-on-missing-document

Conversation

@kpal81xd
Copy link
Copy Markdown
Contributor

@kpal81xd kpal81xd commented Apr 14, 2026

PLAY-CANVAS-G2X7 — 102 events in release:2.20.*

What's Changed

  • When the user_data ShareDB document fails to be created during subscribe, the load event fires with a null type. Previously, userdata.ts would still create an ObserverSync and start forwarding ops, causing every camera movement to produce a ShareDBError: Cannot submit op. Document has not been created — resulting in bursts of 20-30 errors per affected user.
  • Guard the load handler to skip emitting userdata:raw when !data.type (document missing), preventing the sync from starting on a broken document.
  • Guard submitOp with !userData.type as a belt-and-suspenders check for transient null-type states.
  • Move the op listener registration outside the load handler to prevent duplicate listeners if load fires more than once (e.g., after a ShareDB rollback + re-fetch).

Checks

When the collab server fails to create the user_data document during
subscribe, the load event fires with a null type. Previously this
caused a cascade of ShareDB errors on every camera movement. Skip
syncing when the document is missing and guard submitOp against a
null type. Also move the op listener outside the load handler to
prevent duplicate registrations on re-fetch.
@kpal81xd kpal81xd self-assigned this Apr 14, 2026
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 14, 2026

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

Project Deployment Actions Updated (UTC)
editor Ready Ready Preview, Comment Apr 14, 2026 2:48pm

Request Review

@kpal81xd kpal81xd added bug Something isn't working labels Apr 14, 2026
@kpal81xd kpal81xd merged commit 6765163 into main Apr 14, 2026
10 checks passed
@kpal81xd kpal81xd deleted the fix/guard-userdata-submit-on-missing-document branch April 14, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant