Skip to content

getDocsFromCache - Possible inconsistency between API reference and source code #6851

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

Closed
sher-s7 opened this issue Dec 3, 2022 · 1 comment · Fixed by #6879
Closed

getDocsFromCache - Possible inconsistency between API reference and source code #6851

sher-s7 opened this issue Dec 3, 2022 · 1 comment · Fixed by #6879
Assignees

Comments

@sher-s7
Copy link

sher-s7 commented Dec 3, 2022

[REQUIRED] Describe your environment

  • Operating System version: Windows 10 (WSL 1)
  • Browser version: Firefox 107.0.1
  • Firebase SDK version: 9.14.0
  • Firebase Product: firestore

[REQUIRED] Describe the problem

The javascript API reference indicates that getDocsFromCache should return an error if the documents are not currently cached. See here.

However, while using getDocsFromCache in a project today, I noticed it didn't throw any error when trying to get documents that weren't in cache. Instead it just returned the snapshot with size 0. It looks like this is intended behaviour according to this test, but does that align with the API reference? If you scroll up in that test file you'll see that getDocFromCache (singular) is expected to fail when the doc is not in the cache. Let me know if I'm missing something.

Relevant Code:

Error is never thrown, even when documents aren't in cache

  let snap;
  try {
    snap = await getDocsFromCache(ref);
  } catch (error) { // error is never thrown, code in catch block never runs
    console.log(error);
    snap = await getDocs(ref);
  }
  snap.size === 0 // true
@sher-s7 sher-s7 changed the title getDocsFromCache - Possible inconsistency between docs and source code getDocsFromCache - Possible inconsistency between API reference and source code Dec 3, 2022
@MarkDuckworth MarkDuckworth self-assigned this Dec 5, 2022
@MarkDuckworth
Copy link
Contributor

@sher-s7, Thanks for pointing this out! I'll confirm if this is actually a documentation issue and let you know when a fix is coming.

@firebase firebase locked and limited conversation to collaborators Jan 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants