Skip to content

fix(firestore): align updateDoc, onSnapshot and initializeFirestore error handling with firebase-js-sdk - #9392

Open
Mastersam07 wants to merge 4 commits into
mainfrom
fix/firestore-updatedoc-falsy-onsnapshot-errors
Open

Mastersam07 wants to merge 4 commits into
mainfrom
fix/firestore-updatedoc-falsy-onsnapshot-errors

Conversation

@Mastersam07

Copy link
Copy Markdown
Contributor

Description

Three Firestore fixes that bring error handling in line with the firebase-js-sdk:

  • updateDoc: the field/value and FieldPath forms threw synchronously when a value was falsy (0, false, '', null). Those values now pass through. As in the firebase-js-sdk, only a string or FieldPath first argument selects the field/value form, and extra arguments after an update-data object are ignored.
  • initializeFirestore: still returns synchronously, but invalid settings or a failure while applying them were left as an unhandled promise rejection. They are now reported with console.warn. A non-boolean settings.ssl now rejects like the other settings checks instead of throwing.
  • onSnapshot: a lone onNext (or (options, onNext)) was called with (null, error) when the listener failed, so snap => snap.data() threw. Errors now go only to onError / observer.error; with no error handler they are logged with console.error. Unlike the firebase-js-sdk, setLogLevel('silent') does not suppress this log.

Docs are updated in the Firestore usage guide and the v26 migration guide. The branch also adds a note to the contributor validation checklist about a Jest test that needs a local iOS simulator.

Related issues

Release Summary

Firestore: updateDoc accepts falsy values, initializeFirestore reports settings errors with console.warn, and onSnapshot no longer calls a lone success callback with null on error.

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
    • Yes
  • My change supports the following platforms;
    • Android
    • iOS
    • Other (macOS, web)
  • My change includes tests;
    • e2e tests added or updated in packages/\*\*/e2e
    • jest tests added or updated in packages/\*\*/__tests__
  • I have updated TypeScript types that are affected by my change.
  • This is a breaking change;
    • Yes
    • No

Test Plan

  • New Jest suites: updateDoc.test.ts, initializeFirestore.test.ts, onSnapshotCallbacks.test.ts (document and query listeners). Each fails on the previous code and passes with the fix.
  • yarn tsc:compile, yarn tsc:compile:consumer, yarn lint:js, yarn lint:deps, yarn lint:markdown, yarn lint:spellcheck, yarn compare:types, yarn reference:api and yarn attw:check pass.
  • yarn tests:jest: all Firestore suites pass (411 tests); 100% line and branch coverage on the changed code.
  • No native code changed; TypeScript types are unchanged.

Maintainer note: Fixes internal CPRN-554

@russellwheatley russellwheatley added the blocked: do-not-merge Do not merge this issue without approval by the person who labelled this issue as Do Not Merge label Oct 27, 2026
@russellwheatley

russellwheatley commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

blocking until this lands: #9353

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocked: do-not-merge Do not merge this issue without approval by the person who labelled this issue as Do Not Merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants