(url, label)
| 152 | } |
| 153 | |
| 154 | async 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 | |
| 186 | function findPublishProtocolDependencies(manifest) { |
| 187 | const dependenciesWithPublishProtocols = []; |
no test coverage detected