WorryFree Computers   »   [go: up one dir, main page]

Skip to content
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

Uncaught TypeError: e.auth.addAuthTokenListener is not a function #5018

Closed
tomhicks opened this issue Jun 11, 2021 · 14 comments · Fixed by #5023
Closed

Uncaught TypeError: e.auth.addAuthTokenListener is not a function #5018

tomhicks opened this issue Jun 11, 2021 · 14 comments · Fixed by #5023
Assignees

Comments

@tomhicks
Copy link
tomhicks commented Jun 11, 2021

[REQUIRED] Describe your environment

  • Operating System version: mac OS 10.15.7
  • Browser version: Chrome 91
  • Firebase SDK version: 8.6.7
  • Firebase Product: firestore/auth

[REQUIRED] Describe the problem

Crash on startup with error Uncaught TypeError: e.auth.addAuthTokenListener is not a function

Steps to reproduce:

Upgraded a project to 8.6.7 from 8.6.3, and getting the following error as firestore is initialised:

index.js:383 Uncaught TypeError: e.auth.addAuthTokenListener is not a function
    at n (prebuilt-d16b955d-cdb9e87f.js:14583)
    at eval (prebuilt-d16b955d-cdb9e87f.js:14586)
    at Provider.onInit (index.esm.js:302)

By stopping the debugger, I can see the minimised code something like this:

(t) => {
  e.auth = t;
  e.auth.addAuthTokenListener(...);
}

The problem is that the t parameter is true whereas I presume it's supposed to be an auth instance.

Note:

Something interesting when I was investigating...I put my firebase version back to 8.6.3 and ran npm install again, but the problem remained. My assumption is that there's some dependency that wouldn't have gone back down by going from 8.6.7 to 8.6.3 that has the problem.

That was all nonsense. I was editing a different project's package.json!

@jsakas
Copy link
jsakas commented Jun 11, 2021

I am also facing this issue.

Here is a minimal repo similar to my project reproducing the issue: https://github.com/jsakas/firebase-test-sakas

It's a firebase, typescript, webpack project with minimal dependencies.

@sochool
Copy link
sochool commented Jun 12, 2021

We also see the same error message after upgrading to 8.6.7. It was 8.2.0 before and was working properly.

@sochool
Copy link
sochool commented Jun 12, 2021

We also see the same error message after upgrading to 8.6.7. It was 8.2.0 before and was working properly.

Downgraded to 8.6.5 and everything looks fine. "_this.auth.addAuthTokenListener is not a function" This was the problem as mentioned above.

@bigjimhere
Copy link

Same when upgrading to 8.6.7 from 8.4.2 with an app using multiple app instances. The error message was:

TypeError: n.auth.addAuthTokenListener is not a function

Immediately followed by:

FirebaseError: Firebase: Firebase App named '[DEFAULT]' already exists (app/duplicate-app).

8.6.5 works fine.

@philsouth47
Copy link

I also have this issue with the same error messages as above. When I removed my firebase app initialization of .firestore() , it then works fine, but I lose access to that database. I have attempted to change package versions of firebase and firestore without success.

@TPoret
Copy link
TPoret commented Jun 14, 2021

I got the same error when I installed firebase 8.6.2

Same as @philsouth47 , firestore initialization is the cause.

I tried 8.6.5, 8.6.7, it does not fix it.
Downgraded to 8.2.0 and all is fine.

@tazmaniax
Copy link

Reverting from "^8.6.7" to "8.6.5" worked for me

@looptheloop88
Copy link
looptheloop88 commented Jun 14, 2021

Thanks for the report. I was able to reproduce the error using the sample project created and shared by @jsakas. I also confirmed that SDK version 8.6.5 worked fine.

I'm trying to get the common denominator here. For those who are getting the similar error, did you use webpack? I tried using a non webpack project and the SDK version 8.6.7 worked fine.

@tomhicks
Copy link
Author
tomhicks commented Jun 14, 2021

I am using webpack.

Don't know if you saw the detail in the original report, but there's this:

(t) => {
  e.auth = t;  // t is `true` when it's supposed to be some kind of auth object.
  e.auth.addAuthTokenListener(...);
}

One thing I recall seeing is that not only was the parameter named t, but also there was an object in the next outer scope also called t, which might be the object it's meant to refer to?

Maybe an issue with minification?

Kinda guessing, really.

@looptheloop88
Copy link

Thanks for the confirmation @tomhicks! We will check this out and update this thread if we have any information to share.

@roger-ngx
Copy link

confirm that rolling back to 8.6.5 solved the problem

@kaishiro
Copy link

Just wanted to add that I'm also receiving this same error but am not using webpack. Only using a fairly simple Rollup pipeline.
8.6.6 and 8.6.7 both throw the same error. Reverting back to 8.6.5 resolved things in the meantime. Happy to put together a minimal repo for reproduction if needed.

@byrnecode
Copy link

I'm still having this issue on a new project instance of nuxt with @nuxtjs/axios. Been dealing with it since the latest update.

@TPoret
Copy link
TPoret commented Jun 26, 2021

Thanks for the report. I was able to reproduce the error using the sample project created and shared by @jsakas. I also confirmed that SDK version 8.6.5 worked fine.

I'm trying to get the common denominator here. For those who are getting the similar error, did you use webpack? I tried using a non webpack project and the SDK version 8.6.7 worked fine.

Project was created with npx preact-cli create default my-project

Here is my dependency list
"dependencies": {
    "firebase": "^8.6.8",
    "preact": "^10.5.13",
    "preact-render-to-string": "^5.1.19",
    "preact-router": "^3.2.1"
  },
  "devDependencies": {
    "@babel/core": "^7.14.3",
    "@firebase/rules-unit-testing": "^1.3.2",
    "@storybook/addon-actions": "^6.2.9",
    "@storybook/addon-essentials": "^6.2.9",
    "@storybook/addon-links": "^6.2.9",
    "@storybook/preact": "^6.2.9",
    "@testing-library/preact": "^2.0.1",
    "babel-jest": "^26.6.3",
    "babel-loader": "^8.2.2",
    "core-js": "^3.12.1",
    "cypress": "^7.3.0",
    "eslint": "^7.26.0",
    "eslint-config-google": "^0.14.0",
    "eslint-config-preact": "^1.1.4",
    "eslint-plugin-cypress": "^2.11.3",
    "faker": "^5.5.3",
    "firebase-admin": "^9.9.0",
    "jest": "^26.6.3",
    "jest-preset-preact": "^4.0.3",
    "preact-cli": "^3.2.2",
    "sirv-cli": "^1.0.11",
    "storybook-css-modules-preset": "^1.1.1"
  }

@firebase firebase locked and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.