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

Memory leak when running multiple tests #6664

Closed
vojto opened this issue Oct 7, 2022 · 3 comments
Closed

Memory leak when running multiple tests #6664

vojto opened this issue Oct 7, 2022 · 3 comments

Comments

@vojto
Copy link

vojto commented Oct 7, 2022

Describe your environment

  • Operating System version: macOS 12.6
  • Browser version: (no browser)
  • Firebase SDK version: 9.11.0
  • Firebase Product: firestore@9.11.0, firebase-tools@11.14.1

Describe the problem

Testing code that uses Firestore Web SDK doesn't clean up memory between tests. Using firestore.terminate() or firebase.deleteApp doesn't help.

Steps to reproduce:

Clone repo firebase-leak-repro and run yarn test. The process will run out of memory.

Relevant Code:

Given many tests (tested with 50) that look like this:

import { db, app } from "./firebase";
import * as firebase from "@firebase/app";
import * as firestore from "@firebase/firestore";

describe("leak", () => {
  it("leaks", async () => {
    const leaksRef = firestore.collection(db, "leaks");
    const leakRef = firestore.doc(leaksRef, "leak" + Math.random());

    await firestore.setDoc(leakRef, { foo: "bar" });

    await firestore.terminate(db);
    await firebase.deleteApp(app);
  });
});

Process will run out of memory, even though we're cleaning up db and app.

@google-oss-bot
Copy link
Contributor

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@vojto vojto changed the title Memory leak when running (firestore.terminate doesn't work) Memory leak when running multiple tests Oct 7, 2022
@vojto
Copy link
Author

vojto commented Oct 11, 2022

I tried running this all in one test, and couldn't reproduce the leak that way. It could be a Jest issue - see also:

However, in the issues above, it sounds like downgrading from 16.17 to 16.10 fixed the problems. I'm seeing the leaks on all Node versions - 14, 16.10 and 16.17.

@vojto
Copy link
Author

vojto commented Oct 17, 2022

This seems to be a Jest issue. We switched to Vitest, and not seeing memory leaking anymore. Closing.

@vojto vojto closed this as completed Oct 17, 2022
@firebase firebase locked and limited conversation to collaborators Nov 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants