Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.
This repository was archived by the owner on May 20, 2025. It is now read-only.

Static firestore methods return undefined in OTA bundle with code-push-server (Works in full build & with App Center) #113

@romanfanatics

Description

@romanfanatics

Context:

I recently migrated from App Center CodePush to a standalone instance using code-push-server. OTA updates are received and applied correctly, but I encounter a critical issue with my Firestore module.

Issue:

In a full release build, calls to Firestore work correctly. For example, firestore.Timestamp.fromDate(new Date()) and firestore.FieldPath.documentId() return the expected values.
After applying an OTA update, these static methods return undefined. This results in errors like "[TypeError: undefined is not a function]" when executing calls such as:

import firestore from '@react-native-firebase/firestore';
const timestampSevenDaysAgo = firestore.Timestamp.fromDate(sevenDaysAgo);

or

import firestore from '@react-native-firebase/firestore';

const oneWeekAgo = new Date(startDate);
oneWeekAgo.setDate(oneWeekAgo.getDate() - 14);
const oneWeekAgoFormatted = oneWeekAgo.toISOString();

const collection = baseCollection.doc(doc).collection('collection')
            .where(firestore.FieldPath.documentId(), '>=', oneWeekAgoFormatted);

          const unsubscribe = collection?.onSnapshot(querySnapshot => { ...

This issue did not occur with App Center CodePush, even though I used the same code and SDK version.

The issue appear on both iOS and Android on release mode

Hypothesis:

I suspect that this behavior is due to aggressive tree-shaking optimizations during the OTA bundle generation by Metro. Specifically, using static references from firestore. (instead of invoking firestore()) appears to lead to these static methods being considered unused and subsequently removed, whereas they remain intact in a full build.

I added explicit references (using console.log) to force their inclusion, but in the OTA bundle these methods still come out as undefined.

"firestore()." works fine before and after OTA, for example:

import firestore from '@react-native-firebase/firestore';

const docRef = firestore().collection('collection').doc('doc').collection('collection').doc('doc');
const doc = await docRef.get();

Configuration

"react-native": "^0.75.0",
  "react-native-code-push": "^9.0.1",
"@react-native-firebase/firestore": "^21.2.0",

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions