@sylphx/sdk 0.3.5 → 0.3.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/dist/index.d.cts +19 -3
- package/dist/index.d.ts +19 -3
- package/dist/index.js +16 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -5
- package/dist/index.mjs.map +1 -1
- package/dist/nextjs/index.js.map +1 -1
- package/dist/nextjs/index.mjs.map +1 -1
- package/dist/react/index.js +23870 -24195
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +23729 -24065
- package/dist/react/index.mjs.map +1 -1
- package/dist/server/index.js +10 -2
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +10 -2
- package/dist/server/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -2591,14 +2591,18 @@ function createWebhookHandler(config) {
|
|
|
2591
2591
|
};
|
|
2592
2592
|
}
|
|
2593
2593
|
async function cachedFetch(params) {
|
|
2594
|
-
const { url, headers, fallback, label, revalidate = 60 } = params;
|
|
2594
|
+
const { url, headers, fallback, label, revalidate = 60, timeout = 3e3 } = params;
|
|
2595
2595
|
try {
|
|
2596
|
+
const controller = new AbortController();
|
|
2597
|
+
const timer = setTimeout(() => controller.abort(), timeout);
|
|
2596
2598
|
const response = await fetch(url, {
|
|
2597
2599
|
headers,
|
|
2600
|
+
signal: controller.signal,
|
|
2598
2601
|
// @ts-expect-error - Next.js extended fetch option
|
|
2599
2602
|
next: { revalidate }
|
|
2600
2603
|
// Next.js Data Cache with TTL
|
|
2601
2604
|
});
|
|
2605
|
+
clearTimeout(timer);
|
|
2602
2606
|
if (!response.ok) {
|
|
2603
2607
|
console.warn(`[Sylphx] Failed to fetch ${label}:`, response.status);
|
|
2604
2608
|
return fallback;
|
|
@@ -2606,7 +2610,11 @@ async function cachedFetch(params) {
|
|
|
2606
2610
|
const data = await response.json();
|
|
2607
2611
|
return data ?? fallback;
|
|
2608
2612
|
} catch (error) {
|
|
2609
|
-
|
|
2613
|
+
if (error instanceof DOMException && error.name === "AbortError") {
|
|
2614
|
+
console.warn(`[Sylphx] Timeout fetching ${label} (${timeout}ms)`);
|
|
2615
|
+
} else {
|
|
2616
|
+
console.warn(`[Sylphx] Failed to fetch ${label}:`, error);
|
|
2617
|
+
}
|
|
2610
2618
|
return fallback;
|
|
2611
2619
|
}
|
|
2612
2620
|
}
|