You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Explicit gcTime schedules a GC timer during SSR, retaining the whole render in memory #12025
On the server, a query with an explicit finite gcTime (a regular client-side option) schedules a real setTimeout during SSR. The server default of Infinity is meant to prevent this, but an explicit gcTime bypasses it.
In Node, a pending timer keeps the render's async context (AsyncLocalStorage) alive until it fires. As a result, the entire render stays in memory: the HTML, the RSC payload, and the Request held by react-dom/server.
The timer serves no purpose. The request's QueryClient is discarded together with the response, so there is nothing left to garbage-collect.
Our case: Next.js 16, with a single useQuery({ gcTime: 24h }) in the root provider. Every render left behind a 24-hour timer and about 1.4 MB of retained memory. A heap snapshot of an idle replica showed 272 Request objects and 268 pending timers. Replicas grew until they hit the memory limit and were OOM-killed.
@mgarcialeniolabs thanks, but there's already a fix up for review in #12026: on the server the GC timer isn't scheduled for any gcTime. A review there would help more than a second fix.
Activity
mgarcia-improving commentedon Oct 16, 2026
I'll work on this.
AdzerKI commentedon Oct 19, 2026
@mgarcialeniolabs thanks, but there's already a fix up for review in #12026: on the server the GC timer isn't scheduled for any
gcTime. A review there would help more than a second fix.