Closed atsjo closed 9 months ago
I found a few problems with this issue:
Yes, related to https://github.com/firebase/firebase-admin-node/issues/2374
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
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.
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.
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)
Is there a plan to support admin v12? I want the sum and average functionality and this is a blocker
Any updates when firebase-functions will support firebase-admin 12?
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?
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.
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.
(I'll see if I can get the right people's attention on this soon. cc @taeold @blidd-google)
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.
I am facing the same issue with firebase-functions v4.5.0 and firebase-admin v12 :/
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🚀🔥
Any updates on this?
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.
@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 @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.
@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!
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 🤷🏻♀️
@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;
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.
@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!
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()
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?
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..
For anyone still experiencing this problem, update firebase-function-test to 3.1.1 as shown below:
"firebase-functions-test": "^3.1.1",
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....