-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Problem
Pages that render content asynchronously via JavaScript (e.g., GitHub traffic charts, SPAs with data fetching) return incomplete snapshots on initial goto. The first snapshot shows placeholder text like "Loading" or "Crunching the latest data" instead of the actual content.
Currently the workaround is to wait manually (e.g., sleep 5) and then run a separate snapshot command. This is wasteful and unreliable - the delay is a guess.
Proposal
Add a --wait-loaded flag (or similar) to goto that waits for async content to finish rendering before taking the snapshot. Detection heuristics:
- Network idle - wait until no pending XHR/fetch requests for N ms
- DOM stability - wait until no DOM mutations for N ms (similar to
--wait-stableonclick) - Loading indicator absence - wait until common loading patterns disappear (spinners, "Loading..." text, skeleton screens)
Alternatively, make --wait-stable work on goto (currently it's only documented for click).
Example
# Current - requires 2 commands and a guess on timing
node web-ctl.js run session goto https://github.com/org/repo/graphs/traffic
sleep 5
node web-ctl.js run session snapshot
# Proposed - single command, waits for content
node web-ctl.js run session goto https://github.com/org/repo/graphs/traffic --wait-loadedImpact
Reduces round-trips for async pages from 2-3 commands to 1. Eliminates unreliable sleep-based workarounds.