Skip to content

fix(graphile-cache): remove redundant serv.release() to prevent double-release error#685

Merged
pyramation merged 2 commits intodevelop-v5from
fix-graphile-cache-double-release
Feb 5, 2026
Merged

fix(graphile-cache): remove redundant serv.release() to prevent double-release error#685
pyramation merged 2 commits intodevelop-v5from
fix-graphile-cache-double-release

Conversation

@pyramation
Copy link
Contributor

@pyramation pyramation commented Feb 5, 2026

Summary

Fixes the "Release has already been called" error that occurs when disposing PostGraphile v5 cache entries.

The issue was that disposeEntry() was calling entry.serv.release() explicitly, then calling entry.pgl.release(). However, PostGraphile v5's release() method internally calls serv.release() on the grafserv instance, causing grafserv to throw an error on the second release attempt.

The fix removes the explicit serv.release() call and lets pgl.release() handle the grafserv cleanup internally.

Disposal Path Analysis

Analyzed all disposal paths for both pg-cache and graphile-cache:

  • graphile-cache disposal paths: LRU eviction, TTL expiration, manual delete, clearMatchingEntries(), pgCache cleanup callback, and closeAllCaches()
  • Double-disposal prevention: The existing disposedKeys Set correctly prevents double-disposal across all code paths
  • Testing framework usage: Test fixtures (CoreDeployTestFixture, MigrateTestFixture, CLIDeployTestFixture) use pg-cache directly via teardownPgPools() but don't use graphile-cache, so this change doesn't affect them

Review & Testing Checklist for Human

  • Verify that PostGraphile v5's release() does indeed call grafserv's release() internally (see node_modules/.pnpm/postgraphile@5.0.0-rc.4.../node_modules/postgraphile/dist/index.js lines 95-110)
  • Test cache disposal manually by triggering the scenario that caused the original error to confirm it no longer occurs
  • Confirm no resource leaks occur when cache entries are evicted (HTTP server and grafserv should still be properly cleaned up)

Recommended test plan: Run the GraphQL server locally, make requests to populate the graphile cache, then trigger cache eviction (via TTL, LRU pressure, or manual flush) and verify no "Release has already been called" errors appear in logs.

Notes

Requested by @pyramation
Link to Devin run: https://app.devin.ai/sessions/429049b483244251bbfecf110da03d52

…e-release error

PostGraphile v5's pgl.release() internally calls serv.release() on the
grafserv instance. Calling serv.release() explicitly before pgl.release()
causes a 'Release has already been called' error since grafserv throws
when release() is called twice.

The fix removes the explicit serv.release() call and lets pgl.release()
handle the grafserv cleanup internally.
@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@pyramation pyramation merged commit bc89a12 into develop-v5 Feb 5, 2026
13 checks passed
@pyramation pyramation deleted the fix-graphile-cache-double-release branch February 5, 2026 04:49
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

Successfully merging this pull request may close these issues.

1 participant