(url)
| 115 | } |
| 116 | |
| 117 | async function fetchJson(url) { |
| 118 | for (let attempt = 1; attempt <= FETCH_ATTEMPTS; attempt += 1) { |
| 119 | try { |
| 120 | const response = await fetch(url, { headers: { accept: 'application/json' } }); |
| 121 | if (response.status === 404) { |
| 122 | return null; |
| 123 | } |
| 124 | if (response.ok) { |
| 125 | return response.json(); |
| 126 | } |
| 127 | if (attempt === FETCH_ATTEMPTS) { |
| 128 | throw new Error(`registry responded ${response.status}`); |
| 129 | } |
| 130 | } catch (e) { |
| 131 | if (attempt === FETCH_ATTEMPTS) { |
| 132 | throw e; |
| 133 | } |
| 134 | } |
| 135 | await delay(FETCH_RETRY_DELAY_MS); |
| 136 | } |
| 137 | throw new Error('exhausted registry retries'); |
| 138 | } |
| 139 | |
| 140 | // Scoped names must have their separator encoded to address a single version. |
| 141 | function encodeName(name) { |
no test coverage detected