stripe-firebase-extensions
stripe-firebase-extensions copied to clipboard
Service firestore is not available
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
I am having the same problem. When I call getProducts, the stacktrace is:
provider.ts:130 Uncaught (in promise) Error: Service firestore is not available at Provider.getImmediate (provider.ts:130:1) at hh (index.esm2017.js:17846:1) at new FirestoreProductDAO (product.ts:350:1) at getOrInitProductDAO (product.ts:509:1) at getProducts (product.ts:239:1) at findProducts (ProductsPage.tsx:78:1) at ProductsPage.tsx:106:1 at commitHookEffectListMount (react-dom.development.js:23150:1) at commitPassiveMountOnFiber (react-dom.development.js:24926:1) at commitPassiveMountEffects_complete (react-dom.development.js:24891:1)
Trying to access the collection via the regular firebase
package, getFirestore(app)
throws Service firestore is not available
. I know my app is initialized properly, because I can getAuth(app)
, log in users, etc. I first built my code about 10 days ago and it worked smoothly from the start, then a few days ago, it suddenly stopped and now always throws this error. My code around this has not changed, but just to be sure I rolled back to the first commit where I first got it working and the problem is still there. On the Firebase dashboard I can see the collections, the users, etc., just the same as when it previously worked.
- macOS 13.2.1
- "@stripe/firestore-stripe-payments": "0.0.6"
- "firebase": "9.18.0"
- react 18.1
- react-dom 18.1
Have you tried accessing your Firestore collection outside of this package, by just importing the regular Firebase package? When I did that I got the exact same error, which leads me to believe the problem is not with stripe-firebase-extensions, but is a problem on Google's side. I created a brand new Firebase app, then in a web app started with create-react-app, I installed this in package.json:
"firebase": "9.18.0",
These sample lines show how the bug appears with Google's own package:
import { initializeApp } from "firebase/app"; import { getFirestore, collection } from "firebase/firestore"; const fbApp = initializeApp(firebaseConfig); const auth = getAuth(fbApp); // works fine, can log users in, etc. const firestore = getFirestore(fbApp); // EXCEPTION THROWN: Service firestore is not available
I am going back and forth with Google support now to try to get them to see the problem.
Upon further testing, I don't believe this is a Firestore issue, but is a problem with this library. I found that the getFirestore(fbApp) call mentioned in the previous post only throws an exception if @stripe/stripe-firebase-extensions is installed, even though that code does not invoke any code in the @stripe package. If I rebuild node_modules without the @stripe package, the regular calls to Firestore work fine.
@ksnyder hi, sorry for the delay ! I was just working and since 2 days it's not working anymore ! The only thing I changed is to re-install node_modules, so I think you write about something with the @stripe/stripe-firebase-extensions
What do you remove? The entire @stripe/stripe-firebase-extensions ?
I tried that
import {initializeApp} from 'firebase/app';
import {firebaseConfig} from 'src/config';
import {getStripePayments} from "@stripe/firestore-stripe-payments";
import "firebase/auth";
import "firebase/firestore";
export const firebaseApp = initializeApp(firebaseConfig);
export const stripePayments = getStripePayments(firebaseApp, {
productsCollection: "products",
customersCollection: "customers",
});
But nothing working ...
@valentso Yes, after removing @stripe/firestore-stripe-payments, I found that the firebase 9.18.0 package started working again. I have not yet figured out how to replace the functionality provided by @stripe/firestore-stripe-payments, the first step was just to determine the cause of the problem.
To summarize my situation: I started with just firebase 9.18.0 and was able to authorize users and read Firestore collections without a problem. When I first installed @stripe/firestore-stripe-payments, it seemed things were working correctly, but within a few days all calls to Firestore stopped working and instead throwing the error "Service firestore is not available". Note that this error is thrown not only when calling into this library, but also when calling into the regular firebase 9.18.0 package. It's possible this started happening when the Firebase-Stripe extension configured in the Firebase console asked to be upgraded to stripe/[email protected] (I think it had been 0.3.2).
In any case, it seems like this library is no longer maintained and not worth investing more time in, since there are longstanding major issues like https://github.com/stripe/stripe-firebase-extensions/pull/458 that have received no attention from Stripe. It seems @jsteele-stripe is the only Stripe rep looking at this package.
I also contacted Stripe support and they said they could do nothing, that GitHub issues was the only forum, so I think this means this package is dead.
Yes, I am still getting the same error, even with extension version 0.0.7. It is as if using the extension SDK causes firebase package to downgrade (?) and the v9 firebase SDK API is no longer valid.
That said, a workaround I've found is to first install firebase
and all other necessary packages, specified in package.json
, and only then install @invertase/firestore-stripe-extension
separately. However, this is not sustainable. I think there are some serious compatibility issues at the moment, and the extension need to upgrade to using firebase
v10 API.
This is because this repo using outdated firebase. As no one maintains this project, i've created new one @caiyongji/firestore-stripe-payments.