@takosjp/yurucommu-core 4.1.6 → 4.1.7
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/package.json
CHANGED
|
@@ -319,12 +319,15 @@ async function handleCloudflareCache(
|
|
|
319
319
|
cacheKey: string,
|
|
320
320
|
config: CacheConfig,
|
|
321
321
|
): Promise<Response | void> {
|
|
322
|
-
const cache = caches.default;
|
|
323
322
|
const url = new URL(c.req.url);
|
|
324
323
|
const fullCacheKey = new Request(`${url.origin}/_cache${cacheKey}`);
|
|
325
324
|
|
|
325
|
+
let cache: Cache;
|
|
326
326
|
let cachedResponse: Response | undefined;
|
|
327
327
|
try {
|
|
328
|
+
// Some runtimes expose CacheStorage but have no backing cache configured;
|
|
329
|
+
// accessing the default getter can fail before match() is reached.
|
|
330
|
+
cache = caches.default;
|
|
328
331
|
cachedResponse = await cache.match(fullCacheKey);
|
|
329
332
|
} catch (error) {
|
|
330
333
|
if (isDefaultCacheUnavailable(error)) {
|
|
@@ -395,7 +398,7 @@ function isDefaultCacheUnavailable(error: unknown): boolean {
|
|
|
395
398
|
: typeof error === "string"
|
|
396
399
|
? error
|
|
397
400
|
: "";
|
|
398
|
-
return /not permitted to access the default cache|default cache.*(?:not|un)available|Cache API.*not available
|
|
401
|
+
return /not permitted to access the default cache|default cache.*(?:not|un)available|Cache API.*not available|^No Cache was configured\.?$/i.test(
|
|
399
402
|
message,
|
|
400
403
|
);
|
|
401
404
|
}
|