graphile-cache 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -74,6 +74,9 @@ const disposeEntry = async (entry, key) => {
74
74
  catch (err) {
75
75
  log.error(`Error disposing PostGraphile[${key}]:`, err);
76
76
  }
77
+ finally {
78
+ disposedKeys.delete(key);
79
+ }
77
80
  };
78
81
  /**
79
82
  * Determine the eviction reason for a cache entry
@@ -172,26 +175,31 @@ export const closeAllCaches = async (verbose = false) => {
172
175
  if (closePromise.promise)
173
176
  return closePromise.promise;
174
177
  closePromise.promise = (async () => {
175
- if (verbose)
176
- log.info('Closing all server caches...');
177
- // Collect all entries and dispose them properly
178
- const entries = [...graphileCache.entries()];
179
- // Mark all as manual evictions
180
- for (const [key] of entries) {
181
- manualEvictionKeys.add(key);
178
+ try {
179
+ if (verbose)
180
+ log.info('Closing all server caches...');
181
+ // Collect all entries and dispose them properly
182
+ const entries = [...graphileCache.entries()];
183
+ // Mark all as manual evictions
184
+ for (const [key] of entries) {
185
+ manualEvictionKeys.add(key);
186
+ }
187
+ const disposePromises = entries.map(([key, entry]) => disposeEntry(entry, key));
188
+ // Wait for all disposals to complete
189
+ await Promise.allSettled(disposePromises);
190
+ // Clear the cache after disposal (dispose callback will no-op due to disposedKeys)
191
+ graphileCache.clear();
192
+ // Clear disposed keys tracking after full cleanup
193
+ disposedKeys.clear();
194
+ manualEvictionKeys.clear();
195
+ // Close pg pools
196
+ await pgCache.close();
197
+ if (verbose)
198
+ log.success('All caches disposed.');
199
+ }
200
+ finally {
201
+ closePromise.promise = null;
182
202
  }
183
- const disposePromises = entries.map(([key, entry]) => disposeEntry(entry, key));
184
- // Wait for all disposals to complete
185
- await Promise.allSettled(disposePromises);
186
- // Clear the cache after disposal (dispose callback will no-op due to disposedKeys)
187
- graphileCache.clear();
188
- // Clear disposed keys tracking after full cleanup
189
- disposedKeys.clear();
190
- manualEvictionKeys.clear();
191
- // Close pg pools
192
- await pgCache.close();
193
- if (verbose)
194
- log.success('All caches disposed.');
195
203
  })();
196
204
  return closePromise.promise;
197
205
  };
package/graphile-cache.js CHANGED
@@ -81,6 +81,9 @@ const disposeEntry = async (entry, key) => {
81
81
  catch (err) {
82
82
  log.error(`Error disposing PostGraphile[${key}]:`, err);
83
83
  }
84
+ finally {
85
+ disposedKeys.delete(key);
86
+ }
84
87
  };
85
88
  /**
86
89
  * Determine the eviction reason for a cache entry
@@ -179,26 +182,31 @@ const closeAllCaches = async (verbose = false) => {
179
182
  if (closePromise.promise)
180
183
  return closePromise.promise;
181
184
  closePromise.promise = (async () => {
182
- if (verbose)
183
- log.info('Closing all server caches...');
184
- // Collect all entries and dispose them properly
185
- const entries = [...exports.graphileCache.entries()];
186
- // Mark all as manual evictions
187
- for (const [key] of entries) {
188
- manualEvictionKeys.add(key);
185
+ try {
186
+ if (verbose)
187
+ log.info('Closing all server caches...');
188
+ // Collect all entries and dispose them properly
189
+ const entries = [...exports.graphileCache.entries()];
190
+ // Mark all as manual evictions
191
+ for (const [key] of entries) {
192
+ manualEvictionKeys.add(key);
193
+ }
194
+ const disposePromises = entries.map(([key, entry]) => disposeEntry(entry, key));
195
+ // Wait for all disposals to complete
196
+ await Promise.allSettled(disposePromises);
197
+ // Clear the cache after disposal (dispose callback will no-op due to disposedKeys)
198
+ exports.graphileCache.clear();
199
+ // Clear disposed keys tracking after full cleanup
200
+ disposedKeys.clear();
201
+ manualEvictionKeys.clear();
202
+ // Close pg pools
203
+ await pg_cache_1.pgCache.close();
204
+ if (verbose)
205
+ log.success('All caches disposed.');
206
+ }
207
+ finally {
208
+ closePromise.promise = null;
189
209
  }
190
- const disposePromises = entries.map(([key, entry]) => disposeEntry(entry, key));
191
- // Wait for all disposals to complete
192
- await Promise.allSettled(disposePromises);
193
- // Clear the cache after disposal (dispose callback will no-op due to disposedKeys)
194
- exports.graphileCache.clear();
195
- // Clear disposed keys tracking after full cleanup
196
- disposedKeys.clear();
197
- manualEvictionKeys.clear();
198
- // Close pg pools
199
- await pg_cache_1.pgCache.close();
200
- if (verbose)
201
- log.success('All caches disposed.');
202
210
  })();
203
211
  return closePromise.promise;
204
212
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphile-cache",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "author": "Constructive <developers@constructive.io>",
5
5
  "description": "PostGraphile v5 LRU cache with automatic pool cleanup integration",
6
6
  "main": "index.js",
@@ -29,12 +29,12 @@
29
29
  "test:watch": "jest --watch"
30
30
  },
31
31
  "dependencies": {
32
- "@pgpmjs/logger": "^2.1.0",
32
+ "@pgpmjs/logger": "^2.2.0",
33
33
  "express": "^5.2.1",
34
- "grafserv": "^1.0.0-rc.4",
34
+ "grafserv": "1.0.0-rc.6",
35
35
  "lru-cache": "^11.2.4",
36
- "pg-cache": "^3.0.0",
37
- "postgraphile": "^5.0.0-rc.4"
36
+ "pg-cache": "^3.1.0",
37
+ "postgraphile": "5.0.0-rc.7"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/express": "^5.0.6",
@@ -51,5 +51,5 @@
51
51
  "constructive",
52
52
  "v5"
53
53
  ],
54
- "gitHead": "b2daeefe49cdefb3d01ea63cf778fb9b847ab5fe"
54
+ "gitHead": "b758178b808ce0bf451e86c0bd7e92079155db7c"
55
55
  }