MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / main

Function main

telemetry-dashboard/scripts/render-check.mjs:227–456  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

225}
226
227async function main() {
228 const browserPath = findBrowser();
229 if (!browserPath) {
230 console.log('render-check: no Chromium found — skipping.');
231 console.log(' Set CHROME_BIN, or install Chrome; the shell smoke suites cover the rest.');
232 return 0;
233 }
234 console.log(`Browser: ${browserPath}`);
235
236 console.log('Seeding the local D1 fixture…');
237 const seed = run('./scripts/seed-fixture.sh', [], { stdio: 'inherit' });
238 const seeded = await new Promise((resolve) => seed.on('exit', resolve));
239 if (seeded !== 0) throw new Error('seeding failed');
240
241 console.log(`Starting wrangler dev on :${PORT}…`);
242 run('npx', ['wrangler', 'dev', '--port', String(PORT), '--ip', '127.0.0.1']);
243 await waitFor('wrangler dev', async () => (await fetch(`${BASE}/robots.txt`)).ok);
244
245 const password = readFileSync(join(root, '.dev.vars'), 'utf8').match(/^ADMIN_PASSWORD="(.*)"$/m)?.[1];
246 if (!password) throw new Error('no ADMIN_PASSWORD in .dev.vars');
247 const login = await fetch(`${BASE}/login`, {
248 method: 'POST',
249 body: new URLSearchParams({ password }),
250 redirect: 'manual',
251 });
252 const cookie = login.headers.getSetCookie().find((c) => c.startsWith('cg_admin_session='));
253 if (!cookie) throw new Error('login did not set a session cookie');
254 const [name, value] = cookie.split(';')[0].split('=');
255
256 profileDir = mkdtempSync(join(tmpdir(), 'cg-dash-profile-'));
257 // chrome-headless-shell is headless by construction and rejects the flag;
258 // a full Chrome needs it.
259 const headlessFlag = browserPath.includes('headless') ? [] : ['--headless=new'];
260 run(browserPath, [
261 ...headlessFlag,
262 '--disable-gpu',
263 '--no-first-run',
264 '--no-default-browser-check',
265 '--remote-debugging-port=0',
266 `--user-data-dir=${profileDir}`,
267 'about:blank',
268 ]);
269
270 let devtoolsPort = null;
271 await waitFor('the browser', () => {
272 const portFile = join(profileDir, 'DevToolsActivePort');
273 if (!existsSync(portFile)) return false;
274 devtoolsPort = Number(readFileSync(portFile, 'utf8').split('\n')[0]);
275 return Number.isFinite(devtoolsPort) && devtoolsPort > 0;
276 }, 30);
277
278 const version = await (await fetch(`http://127.0.0.1:${devtoolsPort}/json/version`)).json();
279 const cdp = await CDP.connect(version.webSocketDebuggerUrl);
280 const { targetId } = await cdp.send('Target.createTarget', { url: 'about:blank' });
281 const { sessionId } = await cdp.send('Target.attachToTarget', { targetId, flatten: true });
282
283 await cdp.send('Page.enable', {}, sessionId);
284 await cdp.send('Runtime.enable', {}, sessionId);

Callers 1

render-check.mjsFile · 0.70

Calls 14

findBrowserFunction · 0.85
apiGetFunction · 0.85
sameFunction · 0.85
connectMethod · 0.80
evaluateMethod · 0.80
sourceMethod · 0.80
runFunction · 0.70
waitForFunction · 0.70
checkFunction · 0.70
sleepFunction · 0.70
onMethod · 0.65
sendMethod · 0.65

Tested by

no test coverage detected