-
Notifications
You must be signed in to change notification settings - Fork 938
@firebase/auth: Auth (10.1.0): INTERNAL ASSERTION FAILED: Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill #7533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Okay - in FetchProvider, method fetch
I don't have
And there is no fetch method. That's why this is not working. |
Why does it only consider the object 'self' and not 'self' or 'window'? |
Can you provide more detail on your Vite application environment? Is this for server side rendering? |
Hey @rzych112. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically. If you have more information that will help us get to the bottom of this, just add a comment! |
I'm getting the same error, I'm working with Turborepo. This is my function import { Auth, signInWithCustomToken } from 'firebase/auth';
export const customToken = async (auth: Auth, customToken: string) => {
const token = customToken.trim();
if (token.length === 0) await Promise.reject(new Error('Token is empty'));
return await signInWithCustomToken(auth, token);
}; and this is what I got on my console console.error
[2023-08-24T00:40:52.023Z] @firebase/auth: Auth (10.3.0): INTERNAL ASSERTION FAILED: Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill
at Logger.defaultLogHandler [as _logHandler] (../../node_modules/.pnpm/@firebase+logger@0.4.0/node_modules/@firebase/logger/src/logger.ts:115:57)
at Logger.Object.<anonymous>.Logger.error (../../node_modules/.pnpm/@firebase+logger@0.4.0/node_modules/@firebase/logger/src/logger.ts:210:5)
at _logError (../../node_modules/.pnpm/@firebase+auth@1.3.0_@firebase+app@0.9.17/node_modules/@firebase/auth/src/core/util/log.ts:48:15)
at debugFail (../../node_modules/.pnpm/@firebase+auth@1.3.0_@firebase+app@0.9.17/node_modules/@firebase/auth/src/core/util/assert.ts:265:3)
at Function.fetch (../../node_modules/.pnpm/@firebase+auth@1.3.0_@firebase+app@0.9.17/node_modules/@firebase/auth/src/core/util/fetch_provider.ts:46:5)
at ../../node_modules/.pnpm/@firebase+auth@1.3.0_@firebase+app@0.9.17/node_modules/@firebase/auth/src/api/index.ts:137:26
at _performFetchWithErrorHandling (../../node_modules/.pnpm/@firebase+auth@1.3.0_@firebase+app@0.9.17/node_modules/@firebase/auth/src/api/index.ts:158:32)
at _performSignInRequest (../../node_modules/.pnpm/@firebase+auth@1.3.0_@firebase+app@0.9.17/node_modules/@firebase/auth/src/api/index.ts:217:27)
at signInWithCustomToken (../../node_modules/.pnpm/@firebase+auth@1.3.0_@firebase+app@0.9.17/node_modules/@firebase/auth/src/core/strategies/custom_token.ts:47:37) Please let me know how I can help you |
I have the same issue, have you fix that ? :) |
Yes, I followed this guide. In my case, I was trying to initialize Firebase running a function, that's why it was not working for me // firebase.config.ts
import {
initializeApp,
getApps,
getApp,
type FirebaseOptions,
type FirebaseApp,
} from 'firebase/app';
import { getAuth, type Auth } from 'firebase/auth';
const firebaseConfig: FirebaseOptions = {
apiKey: `${process.env.NEXT_PUBLIC_FIREBASE_API_KEY}`,
authDomain: `${process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN}`,
databaseURL: `${process.env.NEXT_PUBLIC_FIREBASE_DATABASE_URL}`,
projectId: `${process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID}`,
storageBucket: `${process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET}`,
messagingSenderId: `${process.env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID}`,
appId: `${process.env.NEXT_PUBLIC_FIREBASE_APP_ID_APPLICANT}`,
measurementId: `${process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID_APPLICANT}`,
};
const app: FirebaseApp =
getApps().length > 0 ? getApp() : initializeApp(firebaseConfig);
const auth: Auth = getAuth(app);
export { auth }; // signin.ts
import { type UserCredential, signInWithCustomToken } from 'firebase/auth';
import { auth } from '../config';
type SigninWithCustomToken = (customToken: string) => Promise<UserCredential>;
export const signinWithCustomToken: SigninWithCustomToken = async (
customToken: string,
): Promise<UserCredential> => {
const token = customToken.trim();
if (token.length === 0) await Promise.reject(new Error('Token is empty'));
return await signInWithCustomToken(auth, token);
}; I have multiple Firebase Apps and I need to change this 2 properties, based on each application {
...
appId: `${process.env.NEXT_PUBLIC_FIREBASE_APP_ID_APPLICANT}`,
measurementId: `${process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID_APPLICANT}`,
} I'm still thinking that it should be possible to only change those properties, but I don't know how to do it yet. |
Hey @rzych112. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically. If you have more information that will help us get to the bottom of this, just add a comment! |
Since there haven't been any recent updates here, I am going to close this issue. @rzych112 if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this. |
Operating System
Ubuntu 16
Browser Version
Chrome 114 on Linux
Firebase SDK Version
10.1
Firebase SDK Product:
Auth
Describe your project's tooling
Vite app
Describe the problem
Hello, I'm having trouble authenticating to firebase only on production build. In the skin: the built Vite application does not fire immediately, but provides a 'load' script, which includes the 'start' method - this script is loaded in another application and there the 'start' method is fired and the application is initialized. So main Vite file doing something like this:
If I run this app by
npm start
and i the web console type window.start(); everything is fine. Init ok, connect to the firebase - okIf I build the application and upload it to firebase hosting with this configuration.
I'll get a link to it:
https://my-app.web.app
When I go to the link, fire the start method through the console as above - still, everything is ok.But when my other application adds this script to itself and tries to initialize it there I get errors, caused by the 'signInWithCustomToken' method. Do you have any ideas on how to investigate more at all?
Steps and code to reproduce issue
@firebase/auth: Auth (10.1.0): INTERNAL ASSERTION FAILED: Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill
at I4 (vendor-6cc30cfd.js:521:339):
at Ee (vendor-6cc30cfd.js:521:30)
at ZT (vendor-6cc30cfd.js:626:1258)
at async PT (vendor-6cc30cfd.js:626:1350)
at async Hk (vendor-6cc30cfd.js:1121:43)
The text was updated successfully, but these errors were encountered: