fix(graphile-cache): remove redundant serv.release() to prevent double-release error#685
Merged
pyramation merged 2 commits intodevelop-v5from Feb 5, 2026
Merged
Conversation
…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.
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the "Release has already been called" error that occurs when disposing PostGraphile v5 cache entries.
The issue was that
disposeEntry()was callingentry.serv.release()explicitly, then callingentry.pgl.release(). However, PostGraphile v5'srelease()method internally callsserv.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 letspgl.release()handle the grafserv cleanup internally.Disposal Path Analysis
Analyzed all disposal paths for both
pg-cacheandgraphile-cache:clearMatchingEntries(), pgCache cleanup callback, andcloseAllCaches()disposedKeysSet correctly prevents double-disposal across all code pathspg-cachedirectly viateardownPgPools()but don't usegraphile-cache, so this change doesn't affect themReview & Testing Checklist for Human
release()does indeed call grafserv'srelease()internally (seenode_modules/.pnpm/postgraphile@5.0.0-rc.4.../node_modules/postgraphile/dist/index.jslines 95-110)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