MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / wait_ready

Function wait_ready

cli/src/engine.rs:164–176  ·  view source on GitHub ↗

Block until the harness has set `window.__edgeReady = true` (worker created, ready for evals).

(tab: &headless_chrome::Tab)

Source from the content-addressed store, hash-verified

162
163/// Block until the harness has set `window.__edgeReady = true` (worker created, ready for evals).
164fn wait_ready(tab: &headless_chrome::Tab) -> Result<()> {
165 let deadline = Instant::now() + READY_TIMEOUT;
166 loop {
167 if Instant::now() > deadline {
168 bail!("timed out after {}s waiting for the runtime to load", READY_TIMEOUT.as_secs());
169 }
170 let raw = tab.evaluate(READY_JS, false).map_err(|e| anyhow!("polling runtime ready: {e}"))?;
171 if raw.value.as_ref().and_then(|v| v.as_bool()) == Some(true) {
172 return Ok(());
173 }
174 thread::sleep(Duration::from_millis(60));
175 }
176}
177
178/// Poll the page, stream each new raw stdout chunk, and resolve when the current eval finishes.
179fn drain<F: FnMut(&str)>(tab: &headless_chrome::Tab, on_line: &mut F) -> Result<Outcome> {

Callers 1

openMethod · 0.85

Calls 1

as_boolMethod · 0.80

Tested by

no test coverage detected