@xforge-dev/forge-kit 0.18.0 → 0.18.1
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/jobs-server.d.ts +3 -1
- package/dist/jobs-server.js +6 -2
- package/package.json +1 -1
package/dist/jobs-server.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { type JobCatalog } from './jobs.js';
|
|
2
2
|
/**
|
|
3
3
|
* Fetches the shared job catalog (Next's fetch cache, one hour by default), validates it and installs it
|
|
4
|
-
* as the registry.
|
|
4
|
+
* as the registry. The fetch gives up after `timeoutMs` (default 3s). Any failure, timeout included, leaves the
|
|
5
|
+
* current catalog in place and warns once per distinct error.
|
|
5
6
|
*/
|
|
6
7
|
export declare function refreshJobCatalog(opts?: {
|
|
7
8
|
url?: string;
|
|
8
9
|
revalidate?: number;
|
|
10
|
+
timeoutMs?: number;
|
|
9
11
|
fetch?: typeof fetch;
|
|
10
12
|
}): Promise<JobCatalog>;
|
package/dist/jobs-server.js
CHANGED
|
@@ -2,12 +2,16 @@ import { getJobCatalog, parseJobCatalog, setJobCatalog, JOB_CATALOG_URL } from '
|
|
|
2
2
|
const warned = new Set();
|
|
3
3
|
/**
|
|
4
4
|
* Fetches the shared job catalog (Next's fetch cache, one hour by default), validates it and installs it
|
|
5
|
-
* as the registry.
|
|
5
|
+
* as the registry. The fetch gives up after `timeoutMs` (default 3s). Any failure, timeout included, leaves the
|
|
6
|
+
* current catalog in place and warns once per distinct error.
|
|
6
7
|
*/
|
|
7
8
|
export async function refreshJobCatalog(opts = {}) {
|
|
8
9
|
const doFetch = opts.fetch ?? fetch;
|
|
9
10
|
try {
|
|
10
|
-
const res = await doFetch(opts.url ?? JOB_CATALOG_URL, {
|
|
11
|
+
const res = await doFetch(opts.url ?? JOB_CATALOG_URL, {
|
|
12
|
+
next: { revalidate: opts.revalidate ?? 3600 },
|
|
13
|
+
signal: AbortSignal.timeout(opts.timeoutMs ?? 3000),
|
|
14
|
+
});
|
|
11
15
|
if (!res.ok)
|
|
12
16
|
throw new Error(`job catalog: HTTP ${res.status}`);
|
|
13
17
|
const next = parseJobCatalog(await res.json());
|