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

Update peer deps for firebase-admin v12 #1496

Closed
atsjo opened this issue Dec 8, 2023 · 28 comments · Fixed by #1509
Closed

Update peer deps for firebase-admin v12 #1496

atsjo opened this issue Dec 8, 2023 · 28 comments · Fixed by #1509

Comments

@atsjo
Copy link

atsjo commented Dec 8, 2023

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
Copy link
Collaborator

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not have all the information required by the template. Looks like you forgot to fill out some sections. Please update the issue with more information.

@bitworxuk
Copy link

Yes, related to firebase/firebase-admin-node#2374

@Blunderchips
Copy link

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
Copy link

CodingDoug commented Dec 10, 2023

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
Copy link

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
Copy link

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
Copy link

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

@tonprince
Copy link

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

@chrisspiegl
Copy link

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
Copy link

AFAIK only possible workaround (which won't work in every case I guess) is to do this #1496 (comment)

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
Copy link

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
Copy link
Contributor

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

@AuriDeimantasDev
Copy link

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
Copy link

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
Copy link

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
Copy link

Any updates on this?

@Blunderchips
Copy link

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
Copy link

@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
Copy link

@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
Copy link

ben519 commented Jan 3, 2024

@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
Copy link

maganap commented Jan 4, 2024

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
Copy link

jits commented Jan 4, 2024

@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;

@Blunderchips
Copy link

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
Copy link

devosos commented Jan 9, 2024

@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
Copy link

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
Copy link

Ryu0118 commented Jan 14, 2024

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
Copy link

ediaStudio commented Jan 15, 2024

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
Copy link

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.