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

getting Possible EventEmitter memory leak detected on firebase functions that use google-cloud/ packages #2072

Closed
jdziek opened this issue Jun 20, 2024 · 5 comments
Assignees
Labels
api: firestore Issues related to the googleapis/nodejs-firestore API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@jdziek
Copy link

jdziek commented Jun 20, 2024

Hi.
I started getting a memory leak warning a few days ago for no apparent reason. I did update packages a few weeks ago but didn't see anything till recently. I updated the packages to the most recent ones again and still got that message.
This warning pops up whenever a function is initiated.

image

  1. Is this a client library issue or a product issue?
    I believe this is a google-cloud package issue. I get this error, particularly in functions that must process files to storage.

  2. Did someone already solve this?
    I've seen it has been an issue in the past but nothing has been raised since then on a current release

Environment details

It happens on gen 2 firebase functions using [email protected] using nodejs 20
OtherGCPp packages that I'm using are
"@google-cloud/documentai": "^8.8.0",
"@google-cloud/firestore": "^7.8.0",
"@google-cloud/pubsub": "^4.5.0",
"@google-cloud/storage": "^7.11.2",
"firebase-admin": "^12.1.1",
"firebase-functions": "^5.0.1",

Here is a snippet of my code. The issue happens in every function that references google-cloud packages, so its not an isolated issue to this particular code, but I thought that it cant hurt including it.


import firestore from "@google-cloud/firestore";
import { InternalServerError } from "@moveready/request-errors/lib/index.js";
import envConfig from "../shared_utilities/envConfig.js";

const client = new firestore.v1.FirestoreAdminClient();

export default {
  async createDbBackup() {
    try {
      const databaseName = client.databasePath(
        envConfig.gcp.projectId,
        "(default)",
      );

      return client
        .exportDocuments({
          name: databaseName,
          outputUriPrefix: `gs://${envConfig.gcp.dbBackupBucket}`,
          collectionIds: [],
        })
        .then(([response]) => {
          logger.info(`Backup creation was successful: ${response.name}`);
          return response;
        })
        .catch((err) => {
          logger.error(err);
          throw new InternalServerError();
        });
    } catch (err) {
      logger.error(err);
      throw err;
    }
  },
};
@jdziek jdziek added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jun 20, 2024
@product-auto-label product-auto-label bot added the api: firestore Issues related to the googleapis/nodejs-firestore API. label Jun 20, 2024
@ehsannas ehsannas self-assigned this Jun 21, 2024
@ehsannas
Copy link
Contributor

Thanks for reporting @jdziek . I'll take a look.

@ehsannas
Copy link
Contributor

From your description ( I did update packages a few weeks ago but didn't see anything till recently), it sounds like the appearance of the warning is irrelevant to the package update? Could you try using the previous package versions and let me know if you continue to see the warning?

@jdziek
Copy link
Author

jdziek commented Jun 24, 2024

Got the warning locally today and it happens on a branch that has pretty much the same dependencies as the main branch, so there might be something to it. Will give it more thorough test on staging/gcp by tomorrow and will give you an update, as functions emulator is a little erratic at best.

@jdziek
Copy link
Author

jdziek commented Jun 25, 2024

Changed some package versions, as you suggested, and still getting that warning.
Not entirely sure what to do now. Gonna change them again to exactly the version I had few months back, and see what happens.
Currently using

    "@google-cloud/documentai": "^8.3.0",
    "@google-cloud/firestore": "^7.7.0",
    "@google-cloud/pubsub": "^4.4.0",
    "@google-cloud/storage": "^7.10.0",
    "firebase-admin": "^11.1.0",
    "firebase-functions": "^4.8.1",
    "firebase-tools":" 13.8.1"

EDIT. Set it to packages I had 5 months ago when I didn't get the warning, but I'm still getting it. Those were

  "firebase-tools": "^13.0.2"
  "@google-cloud/documentai": "^7.3.1",
  "@google-cloud/firestore": "^6.4.1",
  "@google-cloud/pubsub": "^3.4.1",
  "@google-cloud/storage": "^6.7.0",
  "firebase-admin": "^11.3.0",
  "firebase-functions": "^4.5.0",

At this point I'm really not sure what to do. Cant find anything relevant online and cant really ignore the issue either as this is happening on our production environment.

@ehsannas
Copy link
Contributor

Thanks for trying out the different versions, @jdziek. Based on these findings, this is not an issue originating from the Firestore client (this repo). I think the root cause is likely either in the Functions runtime or Functions framework. The stack trace also suggests it might be in functions-framework. Please file an issue in that repository, and feel free to reference this issue.

I will close this ticket, but I'd be happy to work with whoever picks up the Functions issue if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: firestore Issues related to the googleapis/nodejs-firestore API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

2 participants