Repository navigation
fix(sites): keep screenshot worker within one HTTP timeout budget - #15077
Conversation
Parallel Sites E2E runs enqueue many screenshot jobs at once. Each job called the browser twice in series while the HTTP client timeout is 60s, so a loaded browser could leave buildLogs at "capturing started" until after the test's 120s wait expired. Capture light and dark previews concurrently in the Swoole worker, log "started" only once routing is ready, and process one screenshots queue job at a time so Playwright is not flooded. Co-authored-by: Chirag Aggarwal <[email protected]>
|
Review complete. 🟠 1 high 💬 Inline comments (1)
The change pins the screenshots worker to a single coroutine with an inline rationale about Playwright capture load, and extends tests for the screenshots/themes flow (Sites custom-server e2e plus a workers jobs unit test).
Reviewed commit: 71cf41c |
🟢 Tier S · Ready to merge
The PR updates Sites screenshot capture to request light and dark previews concurrently in the worker, records per-theme capture duration, and lowers screenshot queue concurrency to preserve the intended browser request cap. It also updates the deployment deletion E2E completion checks and aligns the Compose generator, checked-in Compose configuration, and self-hosting topology documentation with the new worker limits. Latest changes: The newest commit adds a duration histogram for each light and dark capture, recording elapsed time and success or failure while keeping telemetry errors from affecting screenshot processing.
📂 Walkthrough · 6
Reviewed the commits since |
…hput Queue concurrency is a product default, not part of the CI flake fix. The per-job wall-time race is addressed by parallel theme capture. Co-authored-by: Chirag Aggarwal <[email protected]>
There was a problem hiding this comment.
This PR reduces the screenshots worker concurrency (coroutines 8→1) and updates the related e2e and unit tests, but the new cap is silently overridden in the dedicated worker topology, so the intended fix only takes effect in the combined mode.
Key findings
- 🟠 Dedicated-mode override defeats the screenshots cap — workers.php:61
Security rulesNo new WARNING or ERROR findings from security rules. 6 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
|
@hansi-codes review |
Each job now captures light and dark in parallel, so 8 jobs would put 16 captures on the browser. 4 jobs keeps it at 8 with similar throughput, since each job finishes in about half the time. The dedicated worker's _APP_WORKER_MAX_COROUTINES and the combined pool size (79 -> 75) follow.
commit: |
…-worker-flake-ec62 # Conflicts: # src/Appwrite/Platform/Modules/Functions/Workers/Screenshots.php
Evidence
Flaky failure on
Tests\E2E\Services\Sites\SitesCustomServerTest::testDeleteDeployment(Sites / PostgreSQL dedicated lane): deployment reachesready,buildLogsends withScreenshot capturing started.and never gainsScreenshot capturing finished.orScreenshot capturing failed.before the test’s 120sassertEventuallywindow expires. Reported on three CI runs (2026-10-17–10-23); two passed on rerun. Still observed after e86564f (delete/snapshot race fix).Root cause
The screenshots worker logged “started” then called
Appwrite\Screenshots\Client::create()twice in series (light, then dark). Each HTTP call is bounded by_APP_SITES_TIMEOUT(60s in CI). Worst case wall time for one job is therefore ~120s of browser work plus DB I/O, while the test waits only 120s for a terminal log line. Under load the job can still be inside the first or second capture when the assertion times out, so logs stay at “started” with no “failed” line yet (the worker has not thrown).Parallel Sites E2E increases how many jobs are in flight, which lengthens queue wait, but the flake signature here is started without any terminal line within 120s while status is already
ready— consistent with the per-job 2× timeout budget, not with production screenshot worker concurrency settings.This is unrelated to the deployment-delete snapshot race fixed in e86564f.
Fix
Screenshotsworker — After routing/bucket checks, capture light and dark concurrently in the Swoole worker (go()+ channel) so one job completes within ~one HTTP timeout instead of two. Log “capturing started” immediately before capture. Sequential fallback when not in a coroutine (unit/CLI).testDeleteDeployment— Treat populatedscreenshotLight/screenshotDarkas completion signals alongside finished/failedbuildLogs(same terminal outcomes the worker already writes).Screenshots concurrency — the
screenshotsqueue drops from 8 to 4 jobs (app/config/workers.php, and_APP_WORKER_MAX_COROUTINES=4onappwrite-worker-screenshotsindocker-compose.ymland the console compose generator). With two captures per job the browser still sees at most 8 at once, and throughput is similar because each job takes about half as long. The combined worker pool size (sum of per-queue caps) goes from 79 to 75.No CI-only browser compose change in this PR: saturated browser requests should hit the existing HTTP timeout and append “failed”, which the test already accepts. If Sites CI still shows pre-timeout stalls after this lands, browser capacity should be tuned in CI compose/env only (e.g.
.githubcompose overlay or workflow env forappwrite-browser), not worker defaults.Verification
tests/unit/Workers/JobsTest.phptests/unit/Screenshots/ClientTest.phptestDeleteDeployment(single run with fix, local compose)appwriteexited on DB/Redis timeouts under sustained load). CI Sites lane remains the authoritative stress test.No retries, sleeps, timeout changes, or weaker failure handling were added.
Related
Related: appwrite-labs/cloud#6673