MCPcopy Create free account
hub / github.com/decaporg/decap-cms / fetchJson

Function fetchJson

scripts/verify-published-packages.mjs:154–184  ·  view source on GitHub ↗
(url, label)

Source from the content-addressed store, hash-verified

152}
153
154async function fetchJson(url, label) {
155 for (let attempt = 1; attempt <= FETCH_ATTEMPTS; attempt++) {
156 let response;
157 try {
158 response = await fetch(url, { headers: { accept: 'application/json' } });
159 } catch (e) {
160 if (attempt === FETCH_ATTEMPTS) {
161 throw new Error(`${label}: ${e.message}`);
162 }
163 await delay(FETCH_RETRY_DELAY_MS);
164 continue;
165 }
166
167 if (response.status === 404) {
168 return null;
169 }
170
171 if (response.ok) {
172 return response.json();
173 }
174
175 // 5xx and rate limits are worth another try; anything else is not.
176 if (attempt === FETCH_ATTEMPTS || (response.status < 500 && response.status !== 429)) {
177 throw new Error(`${label}: registry responded ${response.status}`);
178 }
179
180 await delay(FETCH_RETRY_DELAY_MS);
181 }
182
183 throw new Error(`${label}: exhausted registry retries`);
184}
185
186function findPublishProtocolDependencies(manifest) {
187 const dependenciesWithPublishProtocols = [];

Callers 3

fetchPublishedManifestFunction · 0.70
provenanceCommitFunction · 0.70
checkPackageFunction · 0.70

Calls 1

delayFunction · 0.70

Tested by

no test coverage detected