MCPcopy Create free account
hub / github.com/reactnativecn/react-native-update / waitForRequestReady

Function waitForRequestReady

Example/e2etest/e2e/globalSetup.ts:163–187  ·  view source on GitHub ↗
(
  url: string,
  init: RequestInit,
  label: string,
  timeoutMs = 30000,
)

Source from the content-addressed store, hash-verified

161}
162
163async function waitForRequestReady(
164 url: string,
165 init: RequestInit,
166 label: string,
167 timeoutMs = 30000,
168) {
169 const start = Date.now();
170
171 while (true) {
172 try {
173 const response = await fetch(url, init);
174 if (response.ok) {
175 return;
176 }
177 } catch {
178 // Keep polling until the timeout expires.
179 }
180
181 if (Date.now() - start > timeoutMs) {
182 throw new Error(`${label} did not become ready in time.`);
183 }
184
185 await sleep(300);
186 }
187}
188
189async function warmServer(platform: 'ios' | 'android') {
190 const origin = `http://127.0.0.1:${LOCAL_UPDATE_PORT}`;

Callers 1

warmServerFunction · 0.85

Calls 2

fetchFunction · 0.85
sleepFunction · 0.85

Tested by

no test coverage detected