MCPcopy
hub / github.com/callstack/agent-device / attempt

Function attempt

src/__tests__/test-utils/loopback.ts:85–95  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

83 const deadline = Date.now() + timeoutMs;
84 return new Promise((resolve, reject) => {
85 const attempt = () => {
86 const req = http.get(url, (res) => {
87 res.resume();
88 if ((res.statusCode ?? 500) < 500) {
89 resolve();
90 return;
91 }
92 retry();
93 });
94 req.on('error', retry);
95 };
96 const retry = () => {
97 if (Date.now() >= deadline) {
98 reject(new Error(`Timed out waiting for ${url}.`));

Callers 1

waitForHttpOkFunction · 0.85

Calls 4

retryFunction · 0.85
getMethod · 0.80
resumeMethod · 0.80
resolveFunction · 0.50

Tested by

no test coverage detected