veryfront 0.1.787 → 0.1.788
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.
package/esm/deno.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest-cache.d.ts","sourceRoot":"","sources":["../../../src/src/release-assets/manifest-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAOH,OAAO,EAA6B,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"manifest-cache.d.ts","sourceRoot":"","sources":["../../../src/src/release-assets/manifest-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAOH,OAAO,EAA6B,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AA8B5F;;;;GAIG;AACH,MAAM,WAAW,2BAA2B;IAC1C,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAC1B;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,oBAAoB,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAChE,CAAC;CACH;AAKD;;;;;;GAMG;AACH,wBAAgB,iCAAiC,CAC/C,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,2BAA2B,GACnC,IAAI,CAEN;AAED;;;;GAIG;AACH,wBAAgB,mCAAmC,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAE3E;AAED;;;;;GAKG;AACH,wBAAgB,oCAAoC,CAClD,OAAO,EAAE,2BAA2B,GAAG,SAAS,GAC/C,IAAI,CAMN;AASD,yEAAyE;AACzE,wBAAgB,6BAA6B,IAAI,OAAO,CAKvD;AAOD;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACnC,oBAAoB,GAAG,IAAI,CA+B7B;AAsDD,6EAA6E;AAC7E,wBAAgB,gCAAgC,IAAI,IAAI,CAIvD;AAED,uEAAuE;AACvE,wBAAgB,8BAA8B,IAAI,IAAI,CAGrD"}
|
|
@@ -39,6 +39,8 @@ const manifestCache = new LRUCache({ maxEntries: MAX_CACHED_MANIFESTS });
|
|
|
39
39
|
registerLRUCache("release-asset-manifest-cache", manifestCache);
|
|
40
40
|
/** In-flight fetches, deduped per releaseId. */
|
|
41
41
|
const inFlight = new Map();
|
|
42
|
+
/** Monotonic guard that invalidates pending fetch writers after cache clears. */
|
|
43
|
+
let cacheGeneration = 0;
|
|
42
44
|
/** Per-releaseId fetcher registry (keyed by releaseId). */
|
|
43
45
|
const fetcherRegistry = new Map();
|
|
44
46
|
/**
|
|
@@ -134,9 +136,14 @@ function scheduleFetch(releaseId) {
|
|
|
134
136
|
const active = resolveFetcher(releaseId);
|
|
135
137
|
if (!active)
|
|
136
138
|
return;
|
|
137
|
-
const
|
|
139
|
+
const fetchGeneration = cacheGeneration;
|
|
140
|
+
const token = Symbol(releaseId);
|
|
141
|
+
inFlight.set(releaseId, { generation: fetchGeneration, token });
|
|
142
|
+
void Promise.resolve().then(async () => {
|
|
138
143
|
try {
|
|
139
144
|
const result = await active(releaseId);
|
|
145
|
+
if (fetchGeneration !== cacheGeneration)
|
|
146
|
+
return;
|
|
140
147
|
if (!result) {
|
|
141
148
|
manifestCache.set(releaseId, { manifest: null, expiresAt: Date.now() + NON_READY_TTL_MS });
|
|
142
149
|
return;
|
|
@@ -165,16 +172,21 @@ function scheduleFetch(releaseId) {
|
|
|
165
172
|
releaseId,
|
|
166
173
|
error: error instanceof Error ? error.message : String(error),
|
|
167
174
|
});
|
|
175
|
+
if (fetchGeneration !== cacheGeneration)
|
|
176
|
+
return;
|
|
168
177
|
manifestCache.set(releaseId, { manifest: null, expiresAt: Date.now() + NON_READY_TTL_MS });
|
|
169
178
|
}
|
|
170
179
|
finally {
|
|
171
|
-
inFlight.
|
|
180
|
+
const current = inFlight.get(releaseId);
|
|
181
|
+
if (current?.token === token && current.generation === fetchGeneration) {
|
|
182
|
+
inFlight.delete(releaseId);
|
|
183
|
+
}
|
|
172
184
|
}
|
|
173
|
-
})
|
|
174
|
-
inFlight.set(releaseId, promise);
|
|
185
|
+
});
|
|
175
186
|
}
|
|
176
187
|
/** Clear cached manifest bodies while keeping registered fetchers intact. */
|
|
177
188
|
export function clearCachedReleaseAssetManifests() {
|
|
189
|
+
cacheGeneration++;
|
|
178
190
|
manifestCache.clear();
|
|
179
191
|
inFlight.clear();
|
|
180
192
|
}
|