firebase / firebase-functions

Firebase SDK for Cloud Functions
https://firebase.google.com/docs/functions/
MIT License
1.02k stars 201 forks source link

Update peer deps for firebase-admin v12 #1496

Closed atsjo closed 9 months ago

atsjo commented 9 months ago

Related issues

[REQUIRED] Version info

node:

v20.10.0

firebase-functions:

4.5.0

firebase-tools:

13.0.0

firebase-admin:

12.0.0

[REQUIRED] Test case

[REQUIRED] Steps to reproduce

update firebase-admin to v12

[REQUIRED] Expected behavior

no warning about peer deps for firebase-admin

[REQUIRED] Actual behavior

 WARN  Issues with peer dependencies found . └─┬ firebase-functions 4.5.0 └── ✕ unmet peer firebase-admin@"^10.0.0 || ^11.0.0": found 12.0.0

Were you able to successfully deploy your functions?

not tried, but probably yes....

google-oss-bot commented 9 months ago

I found a few problems with this issue:

bitworxuk commented 9 months ago

Yes, related to https://github.com/firebase/firebase-admin-node/issues/2374

Blunderchips commented 9 months ago

Is this issue related to this error?

error TS2416: Property 'child' in type 'DataSnapshot' is not assignable to the same property in base type 'DataSnapshot'.
  Type '(childPath: string) => DataSnapshot' is not assignable to type '(path: string) => DataSnapshot'.
    Call signature return types 'DataSnapshot' and 'DataSnapshot' are incompatible.
      The types of 'forEach' are incompatible between these types.
        Type '(action: (a: DataSnapshot) => boolean | void) => boolean' is not assignable to type '(action: (a: IteratedDataSnapshot) => boolean | void) => boolean'.
          Types of parameters 'action' and 'action' are incompatible.
            Types of parameters 'a' and 'a' are incompatible.
              Type 'DataSnapshot' is not assignable to type 'IteratedDataSnapshot'.
                Types of property 'key' are incompatible.
                  Type 'string | null' is not assignable to type 'string'.
                    Type 'null' is not assignable to type 'string'.

Occurs on build when trying to update to firebase-admin v12

CodingDoug commented 9 months ago

I ran into what I believe to be a related issue. When mixing firebase-functions 4.5.0 and firebase-admin 12.0.0, the Firestore object provided by firebase-functions Firestore triggers in QueryDocumentSnapshot isn't compatible with FieldValue.serverTimestamp() imported from firebase-admin. So you get error messages like this when using these server timestamps on operations using the provided Firestore:

Value for argument "data" is not a valid Firestore document. Couldn't serialize object of type "ServerTimestampTransform" (found in field "_u"). Firestore doesn't support JavaScript objects with custom prototypes (i.e. objects that were created via the "new" operator).

Also saw this when trying to use a DocumentSnapshot provided by firebase-functions:

Error: Value for argument "refOrQuery" must be a DocumentReference, Query, or AggregateQuery.

A workaround is to not use the Firestore objects provided by firebase-functions in QueryDocumentSnapshot, and instead init firebase-admin separately, using getFirestore() to get a Firestore instance. I am assuming the updating the firebase-admin dependency will fix this.

gbourne1 commented 9 months ago

Related issues

[REQUIRED] Version info

node:

v20.10.0

firebase-functions:

4.5.0

firebase-tools:

13.0.0

firebase-admin:

12.0.0

[REQUIRED] Test case

[REQUIRED] Steps to reproduce

update firebase-admin to v12

[REQUIRED] Expected behavior

no warning about peer deps for firebase-admin

[REQUIRED] Actual behavior

 WARN  Issues with peer dependencies found . └─┬ firebase-functions 4.5.0 └── ✕ unmet peer firebase-admin@"^10.0.0 || ^11.0.0": found 12.0.0

Were you able to successfully deploy your functions?

not tried, but probably yes....

No you are not able to deploy the functions with this per dependency issue.

Blunderchips commented 9 months ago

Is this issue related to this error?

error TS2416: Property 'child' in type 'DataSnapshot' is not assignable to the same property in base type 'DataSnapshot'.
  Type '(childPath: string) => DataSnapshot' is not assignable to type '(path: string) => DataSnapshot'.
    Call signature return types 'DataSnapshot' and 'DataSnapshot' are incompatible.
      The types of 'forEach' are incompatible between these types.
        Type '(action: (a: DataSnapshot) => boolean | void) => boolean' is not assignable to type '(action: (a: IteratedDataSnapshot) => boolean | void) => boolean'.
          Types of parameters 'action' and 'action' are incompatible.
            Types of parameters 'a' and 'a' are incompatible.
              Type 'DataSnapshot' is not assignable to type 'IteratedDataSnapshot'.
                Types of property 'key' are incompatible.
                  Type 'string | null' is not assignable to type 'string'.
                    Type 'null' is not assignable to type 'string'.

Occurs on build when trying to update to firebase-admin v12

Not sure if I was clear here, we cannot deploy (fails on build)

ksinghal commented 9 months ago

Is there a plan to support admin v12? I want the sum and average functionality and this is a blocker

tonprince commented 9 months ago

Any updates when firebase-functions will support firebase-admin 12?

chrisspiegl commented 9 months ago

I tried as well and my deployment fails with the peer dependency error described above. I really would hope that within the same ecosystem, this would be supported straight out of the box.

Is anyone at Firebase working on this?

AuriDeimantasDev commented 9 months ago

AFAIK only possible workaround (which won't work in every case I guess) is to do this https://github.com/firebase/firebase-functions/issues/1496#issuecomment-1849003059

Hopefully it can be fixed soon, but knowing it's a xmas season, I'd assume fix should be up mid/end of Jan. 🤞 if it could be done this year though.

Blunderchips commented 9 months ago

I tried as well and my deployment fails with the peer dependency error described above. I really would hope that within the same ecosystem, this would be supported straight out of the box.

Is anyone at Firebase working on this?

They seem asleep at the wheel these days. I would not hold my breath for a fix anytime soon.

bkendall commented 9 months ago

(I'll see if I can get the right people's attention on this soon. cc @taeold @blidd-google)

AuriDeimantasDev commented 9 months ago

Feels like devs are not aware of this issue, because yesterday's Firebase Release Notes from @puf highlights feature availability. Yet we're here waiting for the fix.

AnthonyNahas commented 9 months ago

I am facing the same issue with firebase-functions v4.5.0 and firebase-admin v12 :/

Screenshot 2023-12-29 at 15 30 40

KishiTheMechanic commented 9 months ago

I had the same issue with firebase-admin v12.0.0 and firebase-functions v4.5.0

I asked this to Firebase Support and they guided me to here and they said downgrade the firebase-admin.

For me, use

"firebase-admin": "11.10.1"

is just working.

I hope it could help someone like me.

Thank you always! Happy Coding!

LFG🚀🔥

JonasTriki commented 9 months ago

Any updates on this?

Blunderchips commented 9 months ago

I can't even install the latest versions of the packages without there being problems. sadly this project has "about to be sunsetted by google" vibes.

Yes, given the teams reluctances to fix any issues over the past months it seems to be the only conclusion we can come to.

chrisspiegl commented 9 months ago

@Blunderchips @gabrieljbaker I may not be happy with the way the releases are managed. But given that v12 of the firebase-admin SDK was just released, and they completely overhauled the deployment of functions within the last couple of months (to speed it up)… I don't see where this conclusion is coming from.

Yes, I would prefer if this had been supported right out of the gate with the release of v12 of the firebase-admin package… But you have the option to lock your versions, and then you're fine for now.

One month (and around Christmas / Holidays / New Years) really isn't a long enough time for them to be called “not caring”.

Blunderchips commented 9 months ago

@Blunderchips @gabrieljbaker I may not be happy with the way the releases are managed. But given that v12 of the firebase-admin SDK was just released, and they completely overhauled the deployment of functions within the last couple of months (to speed it up)… I don't see where this conclusion is coming from.

Yes, I would prefer if this had been supported right out of the gate with the release of v12 of the firebase-admin package… But you have the option to lock your versions, and then you're fine for now.

One month (and around Christmas / Holidays / New Years) really isn't a long enough time for them to be called “not caring”.

Hi @chrisspiegl yes I would agree with you if this issue happened in isolation but it is following a trend that has been on going for most of last year.

ben519 commented 9 months ago

@Firebase_team, do you have an ETA on this? Not trying to rush you! Just trying to get a rough idea if it's going to be a week, a month, or a year before this is fixed.? And it'd be great just to hear that someone on the team is aware of the issue.

Thanks!

maganap commented 8 months ago

I ran into what I believe to be a related issue. When mixing firebase-functions 4.5.0 and firebase-admin 12.0.0, the Firestore object provided by firebase-functions Firestore triggers in QueryDocumentSnapshot isn't compatible with FieldValue.serverTimestamp() imported from firebase-admin. So you get error messages like this when using these server timestamps on operations using the provided Firestore:

Value for argument "data" is not a valid Firestore document. Couldn't serialize object of type "ServerTimestampTransform" (found in field "_u"). Firestore doesn't support JavaScript objects with custom prototypes (i.e. objects that were created via the "new" operator).

Also saw this when trying to use a DocumentSnapshot provided by firebase-functions:

Error: Value for argument "refOrQuery" must be a DocumentReference, Query, or AggregateQuery.

A workaround is to not use the Firestore objects provided by firebase-functions in QueryDocumentSnapshot, and instead init firebase-admin separately, using getFirestore() to get a Firestore instance. I am assuming the updating the firebase-admin dependency will fix this.

@taeold Thank you for taking care of this but, isn't this comment from @CodingDoug still an issue? Because this case was closed with a commit limited to update peer dependencies in firebase-funcions package to firebase-admin@12. I thought there would be more to it 🤷🏻‍♀️

jits commented 8 months ago

@taeold – additional to the comment above, there's still the build error (from mismatched types) as also mentioned in https://github.com/firebase/firebase-functions/issues/1444:

node_modules/firebase-functions/lib/common/providers/database.d.ts:80:5 - error TS2416: Property 'child' in type 'DataSnapshot' is not assignable to the same property in base type 'DataSnapshot'.
  Type '(childPath: string) => DataSnapshot' is not assignable to type '(path: string) => DataSnapshot'.
    Call signature return types 'DataSnapshot' and 'DataSnapshot' are incompatible.
      The types of 'forEach' are incompatible between these types.
        Type '(action: (a: DataSnapshot) => boolean | void) => boolean' is not assignable to type '(action: (a: IteratedDataSnapshot) => boolean | void) => boolean'.
          Types of parameters 'action' and 'action' are incompatible.
            Types of parameters 'a' and 'a' are incompatible.
              Type 'DataSnapshot' is not assignable to type 'IteratedDataSnapshot'.
                Types of property 'key' are incompatible.
                  Type 'string | null' is not assignable to type 'string'.
                    Type 'null' is not assignable to type 'string'.

80     child(childPath: string): DataSnapshot;
       ~~~~~

node_modules/firebase-functions/lib/common/providers/database.d.ts:100:5 - error TS2416: Property 'forEach' in type 'DataSnapshot' is not assignable to the same property in base type 'DataSnapshot'.
  Type '(action: (a: DataSnapshot) => boolean | void) => boolean' is not assignable to type '(action: (a: IteratedDataSnapshot) => boolean | void) => boolean'.

100     forEach(action: (a: DataSnapshot) => boolean | void): boolean;
Blunderchips commented 8 months ago

Is this issue related to this error?

error TS2416: Property 'child' in type 'DataSnapshot' is not assignable to the same property in base type 'DataSnapshot'.
  Type '(childPath: string) => DataSnapshot' is not assignable to type '(path: string) => DataSnapshot'.
    Call signature return types 'DataSnapshot' and 'DataSnapshot' are incompatible.
      The types of 'forEach' are incompatible between these types.
        Type '(action: (a: DataSnapshot) => boolean | void) => boolean' is not assignable to type '(action: (a: IteratedDataSnapshot) => boolean | void) => boolean'.
          Types of parameters 'action' and 'action' are incompatible.
            Types of parameters 'a' and 'a' are incompatible.
              Type 'DataSnapshot' is not assignable to type 'IteratedDataSnapshot'.
                Types of property 'key' are incompatible.
                  Type 'string | null' is not assignable to type 'string'.
                    Type 'null' is not assignable to type 'string'.

Occurs on build when trying to update to firebase-admin v12

Yes this is still an issue.

devosos commented 8 months ago

@taeold – additional to the comment above, there's still the build error (from mismatched types) as also mentioned in #1444:

node_modules/firebase-functions/lib/common/providers/database.d.ts:80:5 - error TS2416: Property 'child' in type 'DataSnapshot' is not assignable to the same property in base type 'DataSnapshot'.
  Type '(childPath: string) => DataSnapshot' is not assignable to type '(path: string) => DataSnapshot'.
    Call signature return types 'DataSnapshot' and 'DataSnapshot' are incompatible.
      The types of 'forEach' are incompatible between these types.
        Type '(action: (a: DataSnapshot) => boolean | void) => boolean' is not assignable to type '(action: (a: IteratedDataSnapshot) => boolean | void) => boolean'.
          Types of parameters 'action' and 'action' are incompatible.
            Types of parameters 'a' and 'a' are incompatible.
              Type 'DataSnapshot' is not assignable to type 'IteratedDataSnapshot'.
                Types of property 'key' are incompatible.
                  Type 'string | null' is not assignable to type 'string'.
                    Type 'null' is not assignable to type 'string'.

80     child(childPath: string): DataSnapshot;
       ~~~~~

node_modules/firebase-functions/lib/common/providers/database.d.ts:100:5 - error TS2416: Property 'forEach' in type 'DataSnapshot' is not assignable to the same property in base type 'DataSnapshot'.
  Type '(action: (a: DataSnapshot) => boolean | void) => boolean' is not assignable to type '(action: (a: IteratedDataSnapshot) => boolean | void) => boolean'.

100     forEach(action: (a: DataSnapshot) => boolean | void): boolean;

the issue is still there!

ediaStudio commented 8 months ago

node_modules/firebase-functions/lib/common/providers/database.d.ts:80:5 - error TS2416: Property 'child' in type 'DataSnapshot' is not assignable to the same property in base type 'DataSnapshot'. Type '(childPath: string) => DataSnapshot' is not assignable to type '(path: string) => DataSnapshot'. Call signature return types 'DataSnapshot' and 'DataSnapshot' are incompatible. The types of 'forEach' are incompatible between these types. Type '(action: (a: DataSnapshot) => boolean | void) => boolean' is not assignable to type '(action: (a: IteratedDataSnapshot) => boolean | void) => boolean'. Types of parameters 'action' and 'action' are incompatible. Types of parameters 'a' and 'a' are incompatible. Type 'DataSnapshot' is not assignable to type 'IteratedDataSnapshot'. Types of property 'key' are incompatible. Type 'string | null' is not assignable to type 'string'. Type 'null' is not assignable to type 'string'. 80 child(childPath: string): DataSnapshot;

and

node_modules/firebase-functions/lib/common/providers/database.d.ts:100:5 - error TS2416: Property 'forEach' in type 'DataSnapshot' is not assignable to the same property in base type 'DataSnapshot'. Type '(action: (a: DataSnapshot) => boolean | void) => boolean' is not assignable to type '(action: (a: IteratedDataSnapshot) => boolean | void) => boolean'. 100 forEach(action: (a: DataSnapshot) => boolean | void): boolean; Found 2 errors in the same file, starting at: node_modules/firebase-functions/lib/common/providers/database.d.ts:80

"firebase-admin": "^12.0.0",
"firebase-functions": "^4.6.0",

And without firebase-admin 12 we can't use count() and average()
Ryu0118 commented 8 months ago

Is this issue related to this error?

  Type '(childPath: string) => DataSnapshot' is not assignable to type '(path: string) => DataSnapshot'.
    Call signature return types 'DataSnapshot' and 'DataSnapshot' are incompatible.
      The types of 'forEach' are incompatible between these types.
        Type '(action: (a: DataSnapshot) => boolean | void) => boolean' is not assignable to type '(action: (a: IteratedDataSnapshot) => boolean | void) => boolean'.
          Types of parameters 'action' and 'action' are incompatible.
            Types of parameters 'a' and 'a' are incompatible.
              Type 'DataSnapshot' is not assignable to type 'IteratedDataSnapshot'.
                Types of property 'key' are incompatible.
                  Type 'string | null' is not assignable to type 'string'.
                    Type 'null' is not assignable to type 'string'.

Occurs on build when trying to update to firebase-admin v12

I have found a temporary solution to this problem.

node_modules/firebase-functions/lib/common/providers/database.d.ts First remove the forEach and child methods in this path.

node_modules/@firebase/database-types/index.d.ts Next, delete the forEach and child of the interface DataSnapshot in this path, and the problem is solved.

Is there a way to fix this problem the right way?

ediaStudio commented 8 months ago

Easiest workaround is just to

in this file node_modules/firebase-functions/lib/common/providers/database.d.ts

line100 change from

forEach(action: (a: DataSnapshot) => boolean | void): boolean;

to

forEach(action: (a: any) => boolean | void): boolean;

But for an official fix im afraid we have to wait for a new release..

delebakare commented 6 months ago

For anyone still experiencing this problem, update firebase-function-test to 3.1.1 as shown below:

"firebase-functions-test": "^3.1.1",