Skip to content

Service firestore is not available #509

@valensto

Description

@valensto

Bug report

  • Extension name: [e.g. firestore-stripe-payments]

Describe the bug

I got this error: Uncaught (in promise) Error: Service firestore is not available when I trigger this function

const _getProducts = useCallback(async (): Promise<any> => {
    return await getProducts(stripePayments, {
        includePrices: true,
        activeOnly: true,
    });
}, []);

If I don't use the extensions and implement a classic way like this one, I got an empty array, but no error.

const app = initializeApp(firebaseConfig);
const db = getFirestore(app);

const _getProducts = useCallback(async (): Promise<any> => {
    const productCol = collection(db, 'products');
    const productSnapshot = await getDocs(productCol);
    return productSnapshot.docs.map(doc => doc.data());
}, []);

I notice that when I use Firebase auth to register, everything works fine. I got my entries in Firestore, and I'm logged in.

To Reproduce

Follow steps to install stripe Firebase extensions on the Firebase dashboard.

Then

const firebaseApp = initializeApp({
    apiKey: process.env.REACT_APP_FIREBASE_API_KEY,
    appId: process.env.REACT_APP_FIREBASE_APP_ID,
    authDomain: process.env.REACT_APP_FIREBASE_AUTH_DOMAIN,
    messagingSenderId: process.env.REACT_APP_FIREBASE_MESSAGING_SENDER_ID,
    projectId: process.env.REACT_APP_FIREBASE_PROJECT_ID,
    storageBucket: process.env.REACT_APP_FIREBASE_STORAGE_BUCKET
});

const stripePayments = getStripePayments(firebaseApp, {
    productsCollection: "products",
    customersCollection: "customers",
});

const _getProducts = useCallback(async (): Promise<any> => {
    return await getProducts(stripePayments, {
        includePrices: true,
        activeOnly: true,
    });
}, []);

Then fire _getProducts()

Expected behavior

Working :)

System information

  • OS: [e.g. macOS]
    "@stripe/firestore-stripe-payments": "^0.0.6"
    "firebase": "9.17.1"
    "react": "18.2.0"
    "react-dom": "18.2.0"

Additional context

I tried the solution of #468 but not working

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Opened

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions