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 setting options.timeout per subgraph in transportEntries #303

Open
jaffemd opened this issue Dec 9, 2024 · 0 comments
Open

Comments

@jaffemd
Copy link

jaffemd commented Dec 9, 2024

Versions:

node: 22.10.0
"@graphql-hive/gateway": "1.6.6"
"@graphql-hive/gateway-runtime": "1.3.13"

Hi! We currently have a hive gateway setup to serve a supergraph.

We recently tried adding timeout settings per subgraph. Below is our config:

const allowedHeaders = [
  //...
];

const subgraph1Location = process.env.SUBGRAPH_1_LOCATION;
const subgraph1Timeout = process.env.SUBGRAPH_1_TIMEOUT;

const subgraph2Location = process.env.SUBGRAPH_2_LOCATION;
const subgraph2Timeout = process.env.SUBGRAPH_2_TIMEOUT;

export const gatewayConfig = defineConfig({
  supergraph: "supergraph.graphql",
  port: parseInt(process.env.PORT || "8000"),
  cors: {
    origin: "*",
    methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
    allowedHeaders,
  },
  landingPage: false,
  executionCancellation: true,
  upstreamCancellation: true,
  disableIntrospection: true,
  batching: false,
  pollingInterval: 31_556_952_000,
  maskedErrors: false,
  graphiql: false,

  transportEntries: {
    'subgraph1': {
      location: subgraph1Location,
      options: {
        timeout: subgraph1Timeout,
      },
    },
    'subgraph2': {
      location: subgraph2Location,
      options: {
        timeout: subgraph2Timeout,
      },
    },
  }
});

After a couple of days, we observed a memory leak and traced it to this code change on our side.

Screenshot 2024-12-09 at 11 04 50 AM

After trying several things, the single change that fixed our memory leak was removing the options.timeout setting in transportEntries. We moved the per subgraph timeout to a single setting on the newly added requestTimeout option, and the memory leak was immediately fixed.

  requestTimeout: process.env.REQUEST_TIMEOUT,
  
  transportEntries: {
    'subgraph1': {
      location: subgraph1Location,
    },
    'subgraph2': {
      location: subgraph2Location,
    },
@jaffemd jaffemd changed the title Memory Leak caused by setting options.timeout in transportEntries Memory Leak when setting options.timeout in transportEntries Dec 9, 2024
@jaffemd jaffemd changed the title Memory Leak when setting options.timeout in transportEntries Memory Leak when setting options.timeout per subgraph in transportEntries Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant