Skip to content

firebase.loadFirestoreRules timing out in emulator #1396

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
brianmhunt opened this issue Nov 22, 2018 · 6 comments · Fixed by #1403
Closed

firebase.loadFirestoreRules timing out in emulator #1396

brianmhunt opened this issue Nov 22, 2018 · 6 comments · Fixed by #1403
Assignees

Comments

@brianmhunt
Copy link

brianmhunt commented Nov 22, 2018

Describe your environment

  • Operating System version: _____Mac
$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.14
BuildVersion:	18A391
$ node --version
v10.13.0
  • Browser version: _____N/A
  • Firebase SDK version: _____
    "@firebase/testing": "^0.3.3",
    "firebase": "^5.5.9",
    "firebase-admin": "^6.2.0",
    "firebase-functions": "^2.1.0",
    "firebase-functions-test": "^0.1.5",
    "firebase-tools": "^6.1.1"

Describe the problem

It appears that successive calls to firebase.loadFirestoreRules are increasingly slower, to the point where it quickly becomes unusable.

This is a regression, though I have not been able to pinpoint where, and might be Mac specific.

Relevant Code:

Minimum working reproduction here: brianmhunt/bug-reports#firestore-emulator-timeouts

Steps to reproduce:

Sample output from the reproduction repo:

  firebase emulator
    ✓ does not time out (101ms)
    ✓ does not time out 2 (968ms)
    ✓ does not time out 3 (1316ms)
    ✓ does not time out 4 (2168ms)
    ✓ does not time out 5 (4717ms)
    ✕ does not time out 6 (5009ms)

  ● firebase emulator › does not time out 6

    Timeout - Async callback was not invoked within the 5000ms
    timeout specified by jest.setTimeout.

    Rules loaded in 21 ms

  console.log test/firebase.test.js:17
    App initialized in 2 ms

  console.log test/firebase.test.js:14
    Rules loaded in 900 ms

  console.log test/firebase.test.js:17
    App initialized in 0 ms

  console.log test/firebase.test.js:14
    Rules loaded in 1603 ms

  console.log test/firebase.test.js:17
    App initialized in 0 ms

  console.log test/firebase.test.js:14
    Rules loaded in 2520 ms

  console.log test/firebase.test.js:17
    App initialized in 0 ms

  console.log test/firebase.test.js:14
    Rules loaded in 4417 ms

  console.log test/firebase.test.js:17
    App initialized in 1 ms

@google-oss-bot
Copy link
Contributor

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 seem to follow the issue template. Make sure you provide all the required information.

@brianmhunt
Copy link
Author

Having narrowed down the issue, it can be much simpler to reproduce with:

    await firebase.loadFirestoreRules({ projectId, rules }) // ~20 ms
    await firebase.loadFirestoreRules({ projectId, rules }) // ~900 ms
    await firebase.loadFirestoreRules({ projectId, rules }) // ~1600 ms
    await firebase.loadFirestoreRules({ projectId, rules }) // ~2500 ms
    await firebase.loadFirestoreRules({ projectId, rules }) // ~4400 ms

So the time to load the rules is roughly doubling with every call.

@brianmhunt brianmhunt changed the title Firestore emulator timing out firebase.loadFirestoreRules emulator timing out Nov 23, 2018
@brianmhunt brianmhunt changed the title firebase.loadFirestoreRules emulator timing out firebase.loadFirestoreRules timing out in emulator Nov 23, 2018
@brianmhunt
Copy link
Author

One workaround is to set a very high timeout e.g. in the case of jest jest.setTimeout(50000). This is of course less than ideal.

@ryanpbrewster
Copy link
Contributor

This is likely the same issue that was fixed for the Firestore SDK in #1390

I'll do the same thing in the rules loader

@ryanpbrewster
Copy link
Contributor

As a workaround, you can set the environment variable FIREBASE_FIRESTORE_EMULATOR_ADDRESS=127.0.0.1:8080 to force the testing SDK to connect via ipv4. That should resolve the timeouts.

@brianmhunt
Copy link
Author

Thanks for the updates @ryanpbrewster, glad to see this sorted.

@firebase firebase locked and limited conversation to collaborators Oct 14, 2019
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.

4 participants