apollographql / apollographql/apollo-client-integrations

client-integration-nextjs + ssr-only-secrets causes heap out of memory error

Open
#484 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
556
Forks
53
PR merge metrics
No merged PRs in 30d

Description

Our web service uses client-integration-nextjs and [ssr-only-secrets](https://github.com/phryneas/ssr-only-secrets), but the server has begun throwing heap-out-of-memory errors. After investigating, I found that ssr-only-secrets holds on to the Apollo Client cache object for a long time and never releases it.

I think this issue is related to [Optimism package](https://github.com/benjamn/optimism#readme) as both Apollo and ssr-only-secrets uses the [wrap](https://github.com/benjamn/optimism/blob/main/src/index.ts#L136C17-L136C21) function.

Here is reproduction repo
https://github.com/ktmouk/apollo-next-nonce-mem-leak

Maybe Related?: https://github.com/apollographql/apollo-client-integrations/issues/480

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the reproduction repository to confirm the heap growth using client-integration-nextjs and ssr-only-secrets. Read the linked Optimism wrap implementation and compare it with the related issue; done means identifying why the Apollo Client cache remains retained and verifying that the reproduction no longer exhibits the memory leak.

Written by the indexing model from the issue text.

Assessment

Tech stack
nextjs, typescript
Domain
backend, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.