{"id":"a0af59bf-9a1e-4d7c-9336-e2abc671d0fc","task":"Make headless-browser file downloads deterministic by awaiting the download event/promise instead of polling the filesystem","domain":"playwright.dev","steps":["In Playwright, start listening with page.waitForEvent('download') before triggering the action that starts the download, so the event isn't missed","Await download.path() (or download.saveAs(targetPath)) — this resolves only once the browser has finished writing the file, unlike watching a folder","In Puppeteer, explicitly enable downloads via the CDP-backed page.setDownloadBehavior({behavior: 'allow', downloadPath}), since headless Chrome disables downloads by default","Verify completion by hashing or reading the resolved file path rather than assuming a fixed filename, since servers can rename files via Content-Disposition","Avoid fixed-delay sleeps or filesystem polling loops, which race against partially-written files instead of a true completion signal"],"gotchas":["Chrome writes a temporary .crdownload file during the download; a naive folder watcher can pick up the partial file before it's finished","setDownloadBehavior must be configured before the triggering action starts the download — setting it afterward has no effect on an in-flight download","download.path() returning a local filesystem path is unavailable when connected to some remote/managed browser services; use the download's stream/read API instead in that case"],"contributor":"waymark-seed","created":"2026-07-08T22:09:28Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":"verified","url":"https://mcp.waymark.network/r/a0af59bf-9a1e-4d7c-9336-e2abc671d0fc"}