MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / waitForDevTools

Function waitForDevTools

scripts/e2e-webrtc-reliability.mjs:118–154  ·  view source on GitHub ↗
(chromeProcess, getChromeOutput, getSpawnError)

Source from the content-addressed store, hash-verified

116}
117
118async function waitForDevTools(chromeProcess, getChromeOutput, getSpawnError) {
119 const versionUrl = `http://127.0.0.1:${debugPort}/json/version`;
120 const startedAt = Date.now();
121 while (Date.now() - startedAt < chromeStartupTimeoutMs) {
122 const spawnError = getSpawnError();
123 if (spawnError) {
124 throw new Error(
125 [`Chrome failed to start: ${spawnError.message}`, getChromeOutput()]
126 .filter(Boolean)
127 .join("\n"),
128 );
129 }
130 if (chromeProcess.exitCode !== null || chromeProcess.signalCode !== null) {
131 throw new Error(
132 [
133 `Chrome exited before DevTools became available (exit=${chromeProcess.exitCode}, signal=${chromeProcess.signalCode}).`,
134 getChromeOutput(),
135 ]
136 .filter(Boolean)
137 .join("\n"),
138 );
139 }
140 try {
141 return await fetchJson(versionUrl);
142 } catch {
143 await sleep(100);
144 }
145 }
146 throw new Error(
147 [
148 `Timed out waiting ${chromeStartupTimeoutMs}ms for Chrome DevTools endpoint at ${versionUrl}.`,
149 getChromeOutput(),
150 ]
151 .filter(Boolean)
152 .join("\n"),
153 );
154}
155
156function sleep(ms) {
157 return new Promise((resolve) => setTimeout(resolve, ms));

Callers 1

Calls 2

fetchJsonFunction · 0.70
sleepFunction · 0.70

Tested by

no test coverage detected