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

18.1.0: Firebase "Class extends value undefined is not a constructor or null" #28038

Closed
niwolf opened this issue Jul 11, 2024 · 21 comments
Closed
Labels
needs: repro steps We cannot reproduce the issue with the information given
Milestone

Comments

@niwolf
Copy link

niwolf commented Jul 11, 2024

Which @angular/* package(s) are the source of the bug?

Don't known / other

Is this a regression?

Yes

Description

After updating to version 18.1.0. I am getting the following error on ng-serve:

Watch mode enabled. Watching for file changes...
NOTE: Raw file sizes do not reflect development server per-request transformations.
Re-optimizing dependencies because lockfile has changed
  ➜  Local:   http://localhost:4200/
  ➜  press h + enter to show help
Re-optimizing dependencies because lockfile has changed
15:17:17 [vite] Error when evaluating SSR module /@fs/{pathToRepo}/.angular/cache/18.1.0/vite/deps_ssr/@angular_fire_firestore.js?v=de27081b:
|- TypeError: Class extends value undefined is not a constructor or null
    at node_modules/@firebase/auth/node_modules/undici/lib/fetch/file.js (/{pathToRepo}/.angular/cache/18.1.0/vite/deps_ssr/@angular_fire_firestore.js:5662:36)

Please provide a link to a minimal reproduction of the bug

Please provide the exception or error you saw

15:17:17 [vite] Error when evaluating SSR module /@fs/{pathToRepo}/.angular/cache/18.1.0/vite/deps_ssr/@angular_fire_firestore.js?v=de27081b:
|- TypeError: Class extends value undefined is not a constructor or null
    at node_modules/@firebase/auth/node_modules/undici/lib/fetch/file.js (/{pathToRepo}/.angular/cache/18.1.0/vite/deps_ssr/@angular_fire_firestore.js:5662:36)

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 18.1.0
Node: 18.20.2
Package Manager: npm 10.5.0
OS: darwin arm64

Angular: 18.1.0
... animations, build, cdk, cli, common, compiler, compiler-cli
... core, forms, material, platform-browser
... platform-browser-dynamic, platform-server, router, ssr

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1801.0
@angular-devkit/core         18.1.0
@angular-devkit/schematics   18.1.0
@angular/fire                18.0.1
@schematics/angular          18.1.0
rxjs                         7.8.1
typescript                   5.4.5
zone.js                      0.14.7

Anything else?

No response

@thePunderWoman
Copy link

@niwolf Can you provide a minimal reproduction for us? Otherwise there's nothing actionable here for us to look into.

@ngbot ngbot bot modified the milestone: Backlog Jul 11, 2024
@alxhub alxhub transferred this issue from angular/angular Jul 11, 2024
@alan-agius4 alan-agius4 added the needs: repro steps We cannot reproduce the issue with the information given label Jul 11, 2024
@clcarter
Copy link

Had the same problem. Looks like the issue is caused by conflicting versions of the undici dependency, installed by @angular/fire and @angular-devkit/build-angular.

pnpm why undici
Legend: production dependency, optional only, dev only

[email protected] ~/workspace/webdocs/test

dependencies:
@angular/fire 18.0.1
├─┬ firebase 10.12.3
│ ├─┬ @firebase/auth 1.7.5
│ │ └── undici 5.28.4
│ ├─┬ @firebase/auth-compat 0.5.10
│ │ ├─┬ @firebase/auth 1.7.5
│ │ │ └── undici 5.28.4
│ │ └── undici 5.28.4
│ ├─┬ @firebase/firestore 4.6.4
│ │ └── undici 5.28.4
│ ├─┬ @firebase/firestore-compat 0.3.33
│ │ └─┬ @firebase/firestore 4.6.4
│ │   └── undici 5.28.4
│ ├─┬ @firebase/functions 0.11.6
│ │ └── undici 5.28.4
│ ├─┬ @firebase/functions-compat 0.3.12
│ │ └─┬ @firebase/functions 0.11.6
│ │   └── undici 5.28.4
│ ├─┬ @firebase/storage 0.12.6
│ │ └── undici 5.28.4
│ └─┬ @firebase/storage-compat 0.3.9
│   └─┬ @firebase/storage 0.12.6
│     └── undici 5.28.4
└─┬ rxfire 6.0.5
  └─┬ firebase 10.12.3 peer
    └─┬ @firebase/auth 1.7.5
      └── undici 5.28.4

devDependencies:
@angular-devkit/build-angular 18.1.0
├─┬ @angular/build 18.1.0
│ └── undici 6.19.2
└── undici 6.19.2

Fix was to simply add an override in package.json (Example for pnpm):

  "pnpm": {
    "overrides" : {
      "undici": "6.19.2",
      "undici-types": "6.19.2"
    }
  }

Then, after deleting the lockfile and node_modules, and reinstalling packages, everything worked.

Hope this helps!

@niwolf
Copy link
Author

niwolf commented Jul 12, 2024

@niwolf Can you provide a minimal reproduction for us? Otherwise there's nothing actionable here for us to look into.

@thePunderWoman Unfortunately not really, sorry.
As note: I am using SSR and AngularFire. Before updating the Angular core packages from 18.0.x to 18.1.0 everything was working fine. After updating to 18.1.0 I just got these error messages after ng serve compiled successfully:

08:15:13 [vite] Error when evaluating SSR module /@fs/Users/... {pathToMyRepo}.../.angular/cache/18.1.0/vite/deps_ssr/@angular_fire_firestore.js?v=de27081b:
|- TypeError: Class extends value undefined is not a constructor or null
    at node_modules/@firebase/auth/node_modules/undici/lib/fetch/file.js (/Users/... {pathToMyRepo}.../.angular/cache/18.1.0/vite/deps_ssr/@angular_fire_firestore.js:5662:36)
  at __require2 (/Users/... {pathToMyRepo}.../.angular/cache/18.1.0/vite/deps_ssr/chunk-INDP74QC.js:50:50)
    at node_modules/@firebase/auth/node_modules/undici/lib/fetch/formdata.js (/Users/... {pathToMyRepo}.../.angular/cache/18.1.0/vite/deps_ssr/@angular_fire_firestore.js:5854:9)
    
08:15:13 [vite] Error when evaluating SSR module /main.server.mjs:
|- TypeError: Class extends value undefined is not a constructor or null
    at node_modules/@firebase/auth/node_modules/undici/lib/fetch/file.js (/Users/... {pathToMyRepo}.../.angular/cache/18.1.0/vite/deps_ssr/@angular_fire_firestore.js:5662:36)
  at __require2 (/Users/... {pathToMyRepo}.../.angular/cache/18.1.0/vite/deps_ssr/chunk-INDP74QC.js:50:50)
    at node_modules/@firebase/auth/node_modules/undici/lib/fetch/formdata.js (/Users/... {pathToMyRepo}.../.angular/cache/18.1.0/vite/deps_ssr/@angular_fire_firestore.js:5854:9)
   
08:15:13 [vite] Internal server error: Class extends value undefined is not a constructor or null
      at node_modules/@firebase/auth/node_modules/undici/lib/fetch/file.js (/Users/... {pathToMyRepo}.../.angular/cache/18.1.0/vite/deps_ssr/@angular_fire_firestore.js:5662:36)
      at __require2 (/Users/... {pathToMyRepo}.../.angular/cache/18.1.0/vite/deps_ssr/chunk-INDP74QC.js:50:50)
      at node_modules/@firebase/auth/node_modules/undici/lib/fetch/formdata.js (/Users/... {pathToMyRepo}.../.angular/cache/18.1.0/vite/deps_ssr/@angular_fire_firestore.js:5854:9)

I hope this is helping you.

@niwolf
Copy link
Author

niwolf commented Jul 12, 2024

Had the same problem. Looks like the issue is caused by conflicting versions of the undici dependency, installed by @angular/fire and @angular-devkit/build-angular.

pnpm why undici
Legend: production dependency, optional only, dev only

[email protected] ~/workspace/webdocs/test

dependencies:
@angular/fire 18.0.1
├─┬ firebase 10.12.3
│ ├─┬ @firebase/auth 1.7.5
│ │ └── undici 5.28.4
│ ├─┬ @firebase/auth-compat 0.5.10
│ │ ├─┬ @firebase/auth 1.7.5
│ │ │ └── undici 5.28.4
│ │ └── undici 5.28.4
│ ├─┬ @firebase/firestore 4.6.4
│ │ └── undici 5.28.4
│ ├─┬ @firebase/firestore-compat 0.3.33
│ │ └─┬ @firebase/firestore 4.6.4
│ │   └── undici 5.28.4
│ ├─┬ @firebase/functions 0.11.6
│ │ └── undici 5.28.4
│ ├─┬ @firebase/functions-compat 0.3.12
│ │ └─┬ @firebase/functions 0.11.6
│ │   └── undici 5.28.4
│ ├─┬ @firebase/storage 0.12.6
│ │ └── undici 5.28.4
│ └─┬ @firebase/storage-compat 0.3.9
│   └─┬ @firebase/storage 0.12.6
│     └── undici 5.28.4
└─┬ rxfire 6.0.5
  └─┬ firebase 10.12.3 peer
    └─┬ @firebase/auth 1.7.5
      └── undici 5.28.4

devDependencies:
@angular-devkit/build-angular 18.1.0
├─┬ @angular/build 18.1.0
│ └── undici 6.19.2
└── undici 6.19.2

Fix was to simply add an override in package.json (Example for pnpm):

  "pnpm": {
    "overrides" : {
      "undici": "6.19.2",
      "undici-types": "6.19.2"
    }
  }

Then, after deleting the lockfile and node_modules, and reinstalling packages, everything worked.

Hope this helps!

@clcarter This also seems to work for me. Thank you vm!
Maybe the conflicting versions of the undici dependency, can still be fixed?

@alan-agius4
Copy link
Collaborator

The Angular CLI does not depend on undici; it is solely a devDependency and is not installed in the user's project. The fact that the issue is resolved by the override suggests a problem with undici version 5.28.4, which has been addressed in later versions. Therefore, it is likely that the firebase packages should be updated to use a newer version of undici.

@muuvmuuv

This comment was marked as off-topic.

@niwolf
Copy link
Author

niwolf commented Jul 12, 2024

The Angular CLI does not depend on undici; it is solely a devDependency and is not installed in the user's project. The fact that the issue is resolved by the override suggests a problem with undici version 5.28.4, which has been addressed in later versions. Therefore, it is likely that the firebase packages should be updated to use a newer version of undici.

@alan-agius4 Thanks for your answer.
Ok, I only use AngularFire. Can AngularFire be updated when the firebase packages were updated to use a newer version of undici? So that might fix the issue, won't it?

@alan-agius4
Copy link
Collaborator

AngularFire is managed by the firebase team.

@alan-agius4 alan-agius4 changed the title 18.1.0.: "Class extends value undefined is not a constructor or null" 18.1.0.: Firebas "Class extends value undefined is not a constructor or null" Jul 12, 2024
@alan-agius4 alan-agius4 changed the title 18.1.0.: Firebas "Class extends value undefined is not a constructor or null" 18.1.0.: Firebase "Class extends value undefined is not a constructor or null" Jul 12, 2024
@alan-agius4 alan-agius4 changed the title 18.1.0.: Firebase "Class extends value undefined is not a constructor or null" 18.1.0: Firebase "Class extends value undefined is not a constructor or null" Jul 12, 2024
@niwolf
Copy link
Author

niwolf commented Jul 12, 2024

AngularFire is managed by the firebase team.

Alright, got it. Thanks again!

@alan-agius4
Copy link
Collaborator

Closing this since there are no actionable items for us at this time.

@alan-agius4 alan-agius4 closed this as not planned Won't fix, can't repro, duplicate, stale Jul 15, 2024
@Ken-Wainwright
Copy link

I have the exact same problem. I have setup a new web app project in Visual Code and did not change any code at all. Everything works fine. then I add @angular/fire and the first error I got was No overload matches this call.
Overload 1 of 3, '(options: FirebaseOptions, name?: string | undefined): FirebaseApp', gave the following error.
Object literal may only specify known properties, and '"locationId"' does not exist in type 'FirebaseOptions'.
Overload 2 of 3, '(options: FirebaseOptions, config?: FirebaseAppSettings | undefined): FirebaseApp', gave the following error.
Object literal may only specify known properties, and '"locationId"' does not exist in type 'FirebaseOptions'. [plugin angular-compiler]

I commented out the locationID line but then I got 0:48:08 [vite] Error when evaluating SSR module /@fs/C:/Users/HP ProDesk i5/angularWorkspace/web-app/.angular/cache/18.1.1/vite/deps_ssr/chunk-UEELBQ5E.js?v=9fb4ba3a:
|- TypeError: Class extends value undefined is not a constructor or null
at node_modules/@firebase/auth/node_modules/undici/lib/fetch/file.js (eval
at instantiateModule (file:///C:/Users/HP%20ProDesk%20i5/angularWorkspace/web-app/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:53441:24), :5603:36)
at __require2 (eval at instantiateModule (file:///C:/Users/HP%20ProDesk%20i5/angularWorkspace/web-app/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:53441:24), :53:50)
at node_modules/@firebase/auth/node_modules/undici/lib/fetch/formdata.js (eval at instantiateModule (file:///C:/Users/HP%20ProDesk%20i5/angularWorkspace/web-app/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:53441:24), :5795:9)
at __require2 (eval at instantiateModule (file:///C:/Users/HP%20ProDesk%20i5/angularWorkspace/web-app/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:53441:24), :53:50)
at node_modules/@firebase/auth/node_modules/undici/lib/fetch/body.js (eval
at instantiateModule (file:///C:/Users/HP%20ProDesk%20i5/angularWorkspace/web-app/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:53441:24), :5971:9)
at __require2 (eval at instantiateModule (file:///C:/Users/HP%20ProDesk%20i5/angularWorkspace/web-app/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:53441:24), :53:50)
at node_modules/@firebase/auth/node_modules/undici/lib/fetch/response.js (eval at instantiateModule (file:///C:/Users/HP%20ProDesk%20i5/angularWorkspace/web-app/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:53441:24), :13858:9)
at __require2 (eval at instantiateModule (file:///C:/Users/HP%20ProDesk%20i5/angularWorkspace/web-app/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:53441:24), :53:50)
at node_modules/@firebase/auth/node_modules/undici/index.js (eval at instantiateModule (file:///C:/Users/HP%20ProDesk%20i5/angularWorkspace/web-app/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:53441:24), :19773:33)
at __require2 (eval at instantiateModule (file:///C:/Users/HP%20ProDesk%20i5/angularWorkspace/web-app/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:53441:24), :53:50)

10:48:08 [vite] Error when evaluating SSR module /@fs/C:/Users/HP ProDesk i5/angularWorkspace/web-app/.angular/cache/18.1.1/vite/deps_ssr/@angular_fire_firestore.js?v=9fb4ba3a:
|- TypeError: Class extends value undefined is not a constructor or null
at node_modules/@firebase/auth/node_modules/undici/lib/fetch/file.js (eval
at instantiateModule (file:///C:/Users/HP%20ProDesk%20i5/angularWorkspace/web-app/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:53441:24), :5603:36)
at __require2 (eval at instantiateModule (file:///C:/Users/HP%20ProDesk%20i5/angularWorkspace/web-app/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:53441:24), :53:50)
at node_modules/@firebase/auth/node_modules/undici/lib/fetch/formdata.js (eval at instantiateModule (file:///C:/Users/HP%20ProDesk%20i5/angularWorkspace/web-app/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:53441:24), :5795:9)
at __require2 (eval at instantiateModule (file:///C:/Users/HP%20ProDesk%20i5/angularWorkspace/web-app/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:53441:24), :53:50)
at node_modules/@firebase/auth/node_modules/undici/lib/fetch/body.js (eval
at instantiateModule (file:///C:/Users/HP%20ProDesk%20i5/angularWorkspace/web-app/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:53441:24), :5971:9)
at __require2 (eval at instantiateModule (file:///C:/Users/HP%20ProDesk%20i5/angularWorkspace/web-app/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:53441:24), :53:50)
at node_modules/@firebase/auth/node_modules/undici/lib/fetch/response.js (eval at instantiateModule (file:///C:/Users/HP%20ProDesk%20i5/angularWorkspace/web-app/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:53441:24), :13858:9)
at __require2 (eval at instantiateModule (file:///C:/Users/HP%20ProDesk%20i5/angularWorkspace/web-app/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:53441:24), :53:50)
at node_modules/@firebase/auth/node_modules/undici/index.js (eval at instantiateModule (file:///C:/Users/HP%20ProDesk%20i5/angularWorkspace/web-app/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:53441:24), :19773:33)
at __require2 (eval at instantiateModule (file:///C:/Users/HP%20ProDesk%20i5/angularWorkspace/web-app/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:53441:24), :53:50)

I I decided to check things out and the app runs fine if I comment out
//provideFirestore(() => getFirestore()),
//provideStorage(() => getStorage()),

@JGSolutions
Copy link

@clcarter
what is pnpm? Is it another object nderneath devDependencies?
"devDependencies": { ... },
"pnpm": {
"overrides" : {
"undici": "6.19.2",
"undici-types": "6.19.2"
}
}

@clcarter
Copy link

clcarter commented Jul 20, 2024

pnpm is a package management system, like yarn or npm itself. Here in the package.json file, "pnpm" is a top-level object used to configure pnpm. undici and undici-types are the only dependencies for which I'm enforcing version resolution. You can read more pnpm's package_json page.

For yarn you would either use the yarn set resolution command, or you would add the resolutions object to your package.json.

"resolutions": {
 "undici": "6.19.2",
 "undici-types": "6.19.2"
}

For npm, as of version 8.3, you can use the top-level overrides object:

"overrides" : {
  "undici": "6.19.2",
  "undici-types": "6.19.2"
}

reference: https://stackoverflow.com/questions/52416312/npm-equivalent-of-yarn-resolutions

@JGSolutions
Copy link

thx @clcarter works.

I hope the angularFire team and implement a proper fix for this but. So far so good. :)

@AhsanAyaz
Copy link
Contributor

Thanks @clcarter . That helped! ❤️
Hoping the the firebase team fixes this soon!

@alexdabast
Copy link

@JGSolutions and @AhsanAyaz if no body raise the issue on angular/fire repo I doubt that it will be fixed ...

@JGSolutions
Copy link

Sad!

@saifullahamin
Copy link

@clcarter works, thanks.

@robertIsaac
Copy link

robertIsaac commented Aug 18, 2024

BTW disabling angular cache ng cache disable fix the problem
@alan-agius4 can you take a look why this happen with cache enabled?

@robertIsaac
Copy link

robertIsaac commented Aug 18, 2024

@clcarter using

"overrides" : {
  "undici": "6.19.2",
  "undici-types": "6.19.2"
}

while make ng serve works
it makes my tests fails

    ReferenceError: ReadableStream is not defined
...
    > 5 | import { getAuth } from 'firebase/auth';
        | ^
...
      at Object.<anonymous> (../../node_modules/undici/lib/web/fetch/response.js:536:3)
      at Object.<anonymous> (../../node_modules/undici/lib/web/fetch/index.js:11:5)
      at Object.<anonymous> (../../node_modules/undici/index.js:106:19)
      at Object.<anonymous> (../../node_modules/@firebase/auth/dist/node/totp-e2052706.js:7:14)
      at Object.<anonymous> (../../node_modules/@firebase/auth/dist/node/index.js:5:12)
      at Object.<anonymous> (../../node_modules/firebase/auth/dist/index.cjs.js:5:12)

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: repro steps We cannot reproduce the issue with the information given
Projects
None yet
Development

No branches or pull requests