Skip to content

fix(firestore): handle DocumentReference fields in web deserializer#981

Merged
robingenz merged 1 commit into
mainfrom
fix/issue-975-web-document-reference
May 18, 2026
Merged

fix(firestore): handle DocumentReference fields in web deserializer#981
robingenz merged 1 commit into
mainfrom
fix/issue-975-web-document-reference

Conversation

@robingenz
Copy link
Copy Markdown
Member

Summary

  • Reading a document containing a DocumentReference field on web caused RangeError: Maximum call stack size exceeded because deserializeData had no branch for DocumentReference and fell through to the generic object branch, which recursed into the cyclic _firestore getter.
  • Adds a dedicated branch in deserializeData that returns a { __type__: 'documentReference', id, path } marker, mirroring the existing Timestamp / GeoPoint handling.
  • Adds the symmetric serializeMarker case so a deserialized reference can be written back unchanged (round-trip via doc(getFirestore(), marker.path)).
  • Adds the FirestoreDocumentReference marker interface to definitions.ts.

Test plan

  • Read a document containing a DocumentReference field on web — no RangeError is thrown.
  • Returned data contains { __type__: 'documentReference', id, path } for the reference field.
  • Writing that same marker back via setDocument / updateDocument / addDocument stores it as a real Firestore reference (round-trip).
  • Timestamp, GeoPoint, and other existing data types still serialize/deserialize correctly.

Close #975

Reading a document containing a `DocumentReference` field on web caused
`RangeError: Maximum call stack size exceeded` because `deserializeData`
had no branch for `DocumentReference` and fell through to the generic
object branch, which recursed into the cyclic `_firestore` getter.

Adds dedicated handling that produces a
`{ __type__: 'documentReference', id, path }` marker (mirroring
`Timestamp`/`GeoPoint`) and the symmetric `serializeMarker` case so a
deserialized reference can be written back.

Close #975
Copilot AI review requested due to automatic review settings May 15, 2026 13:27
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a RangeError: Maximum call stack size exceeded in the Firestore web shim when reading documents containing DocumentReference fields. The web deserializeData previously had no branch for DocumentReference and recursed into the cyclic _firestore getter via the generic object branch. This PR adds dedicated (de)serialization for DocumentReference, mirroring the existing Timestamp / GeoPoint pattern, and exposes a corresponding FirestoreDocumentReference marker interface.

Changes:

  • Add a DocumentReference branch in deserializeData that returns a { __type__: 'documentReference', id, path } marker.
  • Add the symmetric 'documentReference' case in serializeMarker to round-trip the marker via doc(getFirestore(), marker.path).
  • Add the FirestoreDocumentReference marker interface in definitions.ts.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
packages/firestore/src/web.ts Imports DocumentReference from firebase/firestore and adds the deserialize/serialize branches for the new marker.
packages/firestore/src/definitions.ts Adds the new FirestoreDocumentReference marker interface (__type__: 'documentReference', id, path).
.changeset/firestore-web-document-reference.md Adds a patch-level changeset describing the fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 15, 2026

Open in StackBlitz

@capacitor-firebase/analytics

npm i https://pkg.pr.new/capawesome-team/capacitor-firebase/@capacitor-firebase/analytics@981

@capacitor-firebase/app

npm i https://pkg.pr.new/capawesome-team/capacitor-firebase/@capacitor-firebase/app@981

@capacitor-firebase/app-check

npm i https://pkg.pr.new/capawesome-team/capacitor-firebase/@capacitor-firebase/app-check@981

@capacitor-firebase/authentication

npm i https://pkg.pr.new/capawesome-team/capacitor-firebase/@capacitor-firebase/authentication@981

@capacitor-firebase/crashlytics

npm i https://pkg.pr.new/capawesome-team/capacitor-firebase/@capacitor-firebase/crashlytics@981

@capacitor-firebase/firestore

npm i https://pkg.pr.new/capawesome-team/capacitor-firebase/@capacitor-firebase/firestore@981

@capacitor-firebase/functions

npm i https://pkg.pr.new/capawesome-team/capacitor-firebase/@capacitor-firebase/functions@981

@capacitor-firebase/messaging

npm i https://pkg.pr.new/capawesome-team/capacitor-firebase/@capacitor-firebase/messaging@981

@capacitor-firebase/performance

npm i https://pkg.pr.new/capawesome-team/capacitor-firebase/@capacitor-firebase/performance@981

@capacitor-firebase/remote-config

npm i https://pkg.pr.new/capawesome-team/capacitor-firebase/@capacitor-firebase/remote-config@981

@capacitor-firebase/storage

npm i https://pkg.pr.new/capawesome-team/capacitor-firebase/@capacitor-firebase/storage@981

commit: a5c4add

@robingenz robingenz self-assigned this May 18, 2026
@robingenz robingenz added bug/fix Something isn't working platform: web Web platform package: firestore labels May 18, 2026
@robingenz robingenz merged commit 79c95bc into main May 18, 2026
7 checks passed
@robingenz robingenz deleted the fix/issue-975-web-document-reference branch May 18, 2026 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug/fix Something isn't working package: firestore platform: web Web platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: DocumentReference fields cause Maximum call stack size exceeded in deserializeData

2 participants