MCPcopy Index your code
hub / github.com/adobe/react-spectrum / waitForServer

Function waitForServer

scripts/testDocs.js:38–63  ·  view source on GitHub ↗
(url, timeout = 30000, interval = 1000)

Source from the content-addressed store, hash-verified

36}
37
38function waitForServer(url, timeout = 30000, interval = 1000) {
39 return new Promise((resolve, reject) => {
40 const startTime = Date.now();
41 const checkServer = () => {
42 http
43 .get(url, res => {
44 if (res.statusCode === 200) {
45 resolve();
46 } else {
47 retryOrFail();
48 }
49 })
50 .on('error', retryOrFail);
51 };
52
53 const retryOrFail = () => {
54 if (Date.now() - startTime < timeout) {
55 setTimeout(checkServer, interval);
56 } else {
57 reject(new Error('Server did not start in time'));
58 }
59 };
60
61 checkServer();
62 });
63}
64
65async function getPageLinks() {
66 const packagePaths = [

Callers 1

testDocsFunction · 0.85

Calls 1

checkServerFunction · 0.85

Tested by

no test coverage detected