Skip to content

Memory leak in execute function #8688

@angelsvirkov

Description

@angelsvirkov

Issue workflow progress

Progress of the issue based on the
Contributor Workflow

Make sure to fork this template and run yarn generate in the terminal.

Please make sure Mesh package versions under package.json matches yours.

  • 2. A failing test has been provided
  • 3. A local solution has been provided
  • 4. A pull request is pending review

Describe the bug

The execute function provided by the configured and created mesh leaks memory.

To Reproduce Steps to reproduce the behavior:

Clone the repo https://github.com/angelsvirkov/graphql-mesh-execute-leak and follow the readme steps to inspect the memory.

Image

Expected behavior

The memory stays stable up to some reasonable margins and does not continuously leak.

Environment:

  • OS: I believe it does not matter

  • @graphql-mesh/...:

    "@graphql-mesh/config": "0.108.7",
    "@graphql-mesh/openapi": "0.109.10",
    "@graphql-mesh/runtime": "0.106.6",
  • NodeJS: I believe it does not matter as long as mesh can run

Additional context

I have been battling this issue for over a week and I cannot seem to identify its direct cause. In my setup I use graphql mesh in a programmatic way in a custom server. Here are a few things which I noticed along my investigation:

  • There seemed to be a small memory leak in older versions as well
  • The leak in our case become much stronger after we switched from version "@graphql-mesh/[email protected]" to "@graphql-mesh/[email protected]" (envelop/core got upgraded to v5 and a few other packages were major

updated)

  • When trying to isolate a ready-made example I saw that the leak was also bigger if we have additional openapi sources even if they are not used.
  • I have also tried using the mesh cli to build a mesh and then import the execute from there so that just in case I didn't miss any abstraction along the way. Nevertheless, the leak was still there

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions