MCPcopy Create free account
hub / github.com/MigoXLab/coderio / waitForServerReady

Function waitForServerReady

src/tools/launch-tool/utils/dev-server-manager.ts:126–144  ·  view source on GitHub ↗
(url: string, timeoutMs: number)

Source from the content-addressed store, hash-verified

124}
125
126async function waitForServerReady(url: string, timeoutMs: number): Promise<boolean> {
127 const start = Date.now();
128 const intervalMs = 400;
129
130 while (Date.now() - start < timeoutMs) {
131 const ok = await new Promise<boolean>(resolve => {
132 const req = http.get(url, res => {
133 res.resume();
134 resolve(res.statusCode !== undefined && res.statusCode >= 200 && res.statusCode < 500);
135 });
136 req.on('error', () => resolve(false));
137 req.setTimeout(500, () => req.destroy());
138 });
139 if (ok) return true;
140 await new Promise(r => setTimeout(r, intervalMs));
141 }
142
143 return false;
144}
145
146export class DevServerManager {
147 private handle: DevServerHandle | null = null;

Callers 1

startMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected