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

makeDocumentSnapshot: TypeError: firestoreService.snapshot_ is not a function #87

Closed
tettoffensive opened this issue Dec 22, 2020 · 11 comments · Fixed by googleapis/nodejs-firestore#1728
Assignees

Comments

@tettoffensive
Copy link

I get the following error when trying to use makeDocumentSnapshot: TypeError: firestoreService.snapshot_ is not a function

It seems that it has to do with the following line:

return firestoreService.snapshot_(proto, readTimeProto, 'json');

My code is as follows:

import FunctionsTest from 'firebase-functions-test';
import onUserWritten from '../onUserWritten.function';

const test = FunctionsTest();

describe('onUserWritten', () => {
  it('should do stuff', async () => {
    const wrapped = test.wrap(onUserWritten);

    const beforeSnap = test.firestore.makeDocumentSnapshot(
      {
        id: 'testUser',
        email: 'a@gmail.com',
      },
      '/users/testUser',
    );
...
@joehan
Copy link
Contributor

joehan commented Jul 7, 2021

First of, apologies for the very delayed response to this - this repo was unmaintained for a bit, but we are trying to bring it back to life. It looks like the root cause here is that we rely on snapshot_ https://github.com/googleapis/nodejs-firestore/blob/master/dev/src/index.ts#L825, which is private. I'm going to chat with my team about how we should fix this, and try to rework this to use public methods.

@jekozyra
Copy link

jekozyra commented Oct 1, 2021

Any updates on this issue?

@HugoGresse
Copy link

HugoGresse commented May 14, 2022

@joehan any news on this issue? Following the officiel doc we need to use the makeDocumentSnapshot.

@HugoGresse
Copy link

Maybe @TheIronDev can help as he is the most recent contributors?
The issue happens with "firebase-functions-test": "^2.0.2",

@TheIronDev
Copy link
Contributor

I can certainly take a look.

Giving a heads up, it might be a minute while I sort through previous history.

@TheIronDev
Copy link
Contributor

@tettoffensive || @HugoGresse

Do either of you have a repo that can reproduce this? I attempted for a while this morning but was not able to reproduce. Might be due to my node version + installed modules.

@tettoffensive
Copy link
Author

@TheIronDev I do not. I reported this a couple years ago. But it seems like snapshot_ is still not an exposed method. So I'm not sure why makeDocumentSnapshot would work for you.

@HugoGresse
Copy link

I've made a small repro : https://github.com/HugoGresse/84-fb-functions-makesnapshot-repro
BUT, the issue is caused by my stub for firestore... which is 🤦 only a PEBKAC issue

@TheIronDev
Copy link
Contributor

@HugoGresse - It wasn't a PEBKAC issue until recently :)

@tettoffensive -

Digging deeper, it looks like this issue was introduced in googleapis/nodejs-firestore#1570, when a bunch of @internal were added.

However,
googleapis/nodejs-firestore#1688 added @private annotations to a handful of the snapshot_ overload signatures.

I believe this makes most of the overloads accessible, with the exception of the first signature that does contain the @internal here

I'll try to open up a cl to change the @internal to @private, stay tuned!

@tettoffensive
Copy link
Author

@TheIronDev Good find. I think when I initially reported it I was working with the firebase-admin package, which I'm not even sure has snapshot_. I'll have to dig since I can't really remember if that's the case or not.

TheIronDev added a commit to TheIronDev/nodejs-firestore that referenced this issue May 18, 2022
This commit removes the @internal annotation from snapshot_,
and fixes firebase/firebase-functions-test#87.

`snapshot_` is currently referenced [here](https://github.com/firebase/firebase-functions-test/blob/master/src/providers/firestore.ts#L99).

[More context here](
firebase/firebase-functions-test#87)

I'm happy to work through better alternatives too.
TheIronDev added a commit to TheIronDev/nodejs-firestore that referenced this issue Aug 24, 2022
This commit removes the @internal annotation from snapshot_,
and fixes firebase/firebase-functions-test#87.

`snapshot_` is currently referenced [here](https://github.com/firebase/firebase-functions-test/blob/master/src/providers/firestore.ts#L99).

[More context here](
firebase/firebase-functions-test#87)

I'm happy to work through better alternatives too.
TheIronDev added a commit to TheIronDev/nodejs-firestore that referenced this issue Sep 14, 2022
This commit removes the @internal annotation from snapshot_,
and fixes firebase/firebase-functions-test#87.

`snapshot_` is currently referenced [here](https://github.com/firebase/firebase-functions-test/blob/master/src/providers/firestore.ts#L99).

[More context here](
firebase/firebase-functions-test#87)

I'm happy to work through better alternatives too.
MarkDuckworth pushed a commit to googleapis/nodejs-firestore that referenced this issue Oct 7, 2022
@TheIronDev TheIronDev self-assigned this Dec 21, 2022
@TheIronDev
Copy link
Contributor

googleapis/nodejs-firestore#1728 got merged, which resolves this issue! 🎉

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

Successfully merging a pull request may close this issue.

5 participants