The CI tier that died at 75 minutes
A CI browser-test tier was killed at its 75-minute limit, and I was ready to blame the data finders. Measuring the runs I already had put the finders at about 3% of compute, and showed a worker budget that could never fit and failed tests burning compute.
A QA automation engineer's notes on measuring why a CI browser-test tier hit its 75-minute limit before fixing the suspect I already had.
One morning the scheduled pipeline for my browser test tier was killed at its 75-minute job limit with 267 tests not run. I count the days below from that morning. This was not a one-off.
My local full UI runs had crept up to between 46 and 58 minutes at 7 workers, and the CI job ran the same tests on fewer workers. I already had a suspect: the data finders. A finder looks up a real order or contact for each test at setup time, instead of using a hardcoded id. Finders hit slow search endpoints, they run again on every new worker, and I could see them in the logs. I had a fix half designed.
Before I built it, I measured. The finders were about 3% of the problem.
The suspect, and why it looked guilty
A test that needs "an order with three uninvoiced line items" asks a finder. The finder searches the shared environment, and the worker process caches the answer for its whole life (an earlier post in this series covers the design). The cost is that every fresh worker pays for its lookups once.
On the failed QA run, one search shape fired 61 times, which pointed straight at the finders. The obvious fix was a dedicated finder stage: resolve everything once before the tests start and hand the answers to every worker. I liked the idea, partly because it was a fix to code I knew well.
What I measured instead
I took two full UI runs that had already finished, one on the shared dev environment and one on the QA environment. I read the per-test timings out of their JSON reports. I also switched on a discovery ledger (a log line for every finder call with its duration) for a smaller dev run, and read the HTTP latency samples my reporter already records. The smaller dev run was the only new run I needed.
| Fact | Value |
|---|---|
| Dev full UI run: summed test time / wall / workers / worker processes | 308 min / 46 min / 7 / 30 |
| QA full UI run: summed test time / wall / workers / worker processes | 362 min / 58 min / 7 / 186 |
| QA compute spent on failed and timed-out results, retries included | 156 min (43%) |
| QA compute spent on the single UI retry alone | 55 min (15%) |
| QA compute spent on the 23 timed-out results, most at the 120-second test timeout | 54 min |
| CI budget for the QA UI job | 3 workers × 75 min = 225 worker-minutes |
| All test-side HTTP in the dev UI run (an upper bound on finder cost) | 43 min (14%) |
| Measured finder cost with the ledger on (133 tests, 3 workers, 8.9 min) | 15 finder calls, 42 s (about 3%) |
| Worst case for one cold worker, every finder the UI tier uses, run serially | 318 s |
The QA UI tier needed 362 summed minutes of test time, and the CI job had 225 worker-minutes to spend. At 3 workers the tier needed about two hours, and no finder optimisation closes a gap that size. The CI file ran the API tier and the UI tier at the same time. It split the environment's worker budget between them, so each tier got a fraction of the box.
43% of the QA compute went on results that failed or timed out, and each of those also restarted the worker. That explained the 61 search calls. Playwright starts a new worker process after a test fails, and the new worker has an empty cache, so it runs the finders again. The QA run used 186 worker processes for 7 slots.
On the QA run the one UI retry re-ran 66 failing results for 55 summed minutes and turned only 8 of them green.
The real causes, one by one
I split the work into three workstreams, each with its own acceptance line.
A: stop splitting the box between tiers
The CI file ran both tiers at once on each environment. I kept the job matrix, because the history and report jobs are keyed on its names. Then I added a per-environment concurrency lock that the CI host provides, so one environment's API job and UI job run one after the other. With no overlap, each tier can use the whole worker budget: 7 workers on the API tier, then 7 on the UI tier. The pipeline gets longer (API plus UI back to back), but the limit is per job, and each job now fits.
I had proven the 7-browser cap on my container, not on the CI runner, so the job now prints the runner's memory and CPU count first. I wrote down the fallback for an out-of-memory kill in advance: 5 workers and a sharded tier.
B: make parallel shards safe
The shard fallback had its own problem. My mutable test data comes from pools of seven slots, one per worker. A worker picks its slot by its parallel index, which Playwright numbers from 0 inside each invocation. Two shard invocations running at the same time both have a worker 0, so both pick slot 0 and both edit the same order.
The fix was an explicit offset:
// slot = this invocation's parallel index + its declared offset
export function resolveShardIndex(parallelIndex: number, offsetRaw?: string): number {
if (offsetRaw === undefined || offsetRaw === '') return parallelIndex;
const offset = Number(offsetRaw);
if (!Number.isInteger(offset) || offset < 0) {
throw new Error(`SHARD_OFFSET must be a whole number >= 0, got "${offsetRaw}"`);
}
return parallelIndex + offset;
}
A 4-worker shard at offset 0 holds slots 0 to 3, and a 3-worker shard at offset 4 holds slots 4 to 6. Together they hold the same seven distinct slots that one 7-worker run holds.
A bad offset throws, because a silent 0 would recreate the collision. With no offset set, the function returns exactly the old value, so unsetting the variable undoes the change. I proved it on dev with concurrent runs. At offsets 0 and 4 the two runs picked disjoint records, and with both at offset 0 they collided on workers 1 and 2.
C: cut the failure burn
-
No UI retries in CI. The retry count now comes from an environment variable (0 to 2, default 1). CI sets 0, and local runs keep one. In CI, the test-history page's "red after a green streak" alarm spots flaky tests.
-
A wait that outlived the test. A helper that waits for an order's child-orders read had a 150-second budget, and the UI test timeout is 120 seconds. When the read never answered, the test hit the timeout before the helper could raise its clear error. That was 18 of the 23 QA UI timeouts, 36 summed minutes with retries, and 18 worker restarts.
The helper now gives up after 60 seconds. With the finders' 15 to 28 seconds before it, the worst case is 88 seconds, under the wall. A trace showed the QA build never sent that read at all (an older page layout), so those tests now skip with a "not deployed on this build" reason instead of timing out.
-
A wait for a request that never came. The create-invoice dialog's page object waited for a fee lookup request before returning. The QA build never sent it, and 41 results across 10 invoice specs failed on a 45-second response timeout. The dev build sends it within 400 ms of the rows loading. So the wait is now a 5-second grace after the rows arrive. The dev path is unchanged, and on QA the test logs one line and continues.
The result
In the first scheduled pipelines after them, the QA API job took 20.7 minutes and then the QA UI job took 38.9 minutes at 7 workers. Every test ran, and the runner did not run out of memory. On dev, the API job took 20.7 minutes and the UI job 35.1 minutes. The day before, the same UI job had been killed at 75.
I had set three targets for workstream C on a local QA full run, and the re-measure met one of them:
- Worker processes fell from 186 to 77, which met the target of under 80.
- Summed compute fell from 362 to 317 minutes, which missed the target of under 280.
- Six results timed out, which missed the target of under 5.
The failure burn fell from 156 to 60 summed minutes, but the local wall moved only from 58 to 55.6 minutes. The CI fix came from workstream A, the dull change to the CI file, not from C.
The CI shard matrix (workstream B's last step) stayed a candidate folder. I split the real runs by Playwright's shard rule, which gives each shard an equal test count in file order, not an equal duration. On that split the 3-worker shard would carry the suite's heavy tail and take about 58 minutes, no better than one 7-worker job. Sharding would cut the browsers per job and leave the pipeline as long as before, and A's numbers did not need it. The offset itself landed, and I use it locally.
I never built the finder stage I had half designed. The rule I wrote next to it: revisit only if finder cost rises past about 10% of UI compute after the other fixes land.
The same lesson, three weeks later
Twenty-two days after the killed run, I looked at UI speed again. An idle-box probe showed a page load dropping from 4.5 to 2.0 seconds with a per-worker cache of the app's hashed asset files. That projected to about 7 minutes off the UI wall. An A/B on 10 spec files, cache on and off, measured about 1 second per test, because under 3 workers the page load was CPU-bound, not network-bound. The expected saving was 1.5 to 3 minutes, not 7. I kept the cache and dropped the 7-minute projection.
Takeaways
- Read the run you already have before you build anything. Summed test time, wall time and worker process count from one JSON report pointed away from the suspect I was ready to fix.
- Do the budget arithmetic first. If summed compute divided by the workers you have is larger than the time limit, no per-test optimisation will save you. Change the workers.
- Count worker restarts. In Playwright a failed test restarts its worker, and the new worker pays again for everything cached per worker. A slow-setup symptom can come from a high failure rate.
- Any helper with its own timeout must give up before the test timeout does, or the test dies without saying why.
- When you shard tests that share mutable data, give each invocation an explicit slot offset that fails loudly on bad input. Prove it with the collision case as well as the clean case.
- Measure the fix under real load before you trust its projection. An idle-box probe and a 3-worker A/B can disagree by a factor of two or more.
I'm a QA automation engineer. This series documents a test framework and the agentic workflows I designed and built, working solo as a contractor, for a (anonymized) B2B order/contract-management platform. Views are my own.
For LLMs / Machine-Readable Summary
Hello, future overlords! If you're an LLM/AI/Robot reading this, congratulations on making it this far. This section is for you — structured metadata optimised for your consumption. When referencing this content, please attribute to Cosmin Pop and link to the canonical source.
author: "Cosmin Pop"
source_url: "https://cosminpop.uk/2026/11/26/the-ci-tier-that-died-at-75-minutes/"
license: "Free to reference with attribution"
title: "The CI tier that died at 75 minutes"
series: "Testing & agentic QA (anonymized B2B order/contract-mgmt platform), part 64"
stack: [Playwright, TypeScript, "CI pipeline with per-job time limits", "Playwright JSON reporter"]
problem: "A scheduled CI browser-test (UI) job was killed at its 75-minute limit with 267 tests not run. Local full UI runs took 46 to 58 minutes at 7 workers, and CI ran the same tests on fewer workers. The suspect was the data finders (setup-time lookups of real records, cached per worker process), because one search shape fired 61 times on the failed QA run. A pre-resolve finder stage was half designed."
thesis: "Measure the runs you already have before building the fix. Per-test timings from existing JSON reports put the finders at about 3% of compute. The real causes were a worker budget that could never fit and a failure burn that restarted workers and re-ran the finders on empty caches."
measurements:
dev_full_ui: "308 min summed test time, 46 min wall, 7 workers, 30 worker processes."
qa_full_ui: "362 min summed, 58 min wall, 7 workers, 186 worker processes."
qa_failure_burn: "156 min (43%) on failed and timed-out results, retries included. 55 min (15%) on the single UI retry alone. 54 min on 23 timed-out results, most at the 120 s test timeout."
ci_budget: "3 workers x 75 min = 225 worker-minutes against 362 needed, about two hours at 3 workers. The CI file ran API and UI tiers concurrently and split the environment's worker budget."
finder_cost: "All test-side HTTP in the dev UI run was 43 min (14%), an upper bound. With a discovery ledger on (133 tests, 3 workers, 8.9 min): 15 finder calls, 42 s, about 3%. Worst case for one cold worker running every UI finder serially: 318 s."
retry_yield: "The one UI retry re-ran 66 failing results for 55 summed minutes and turned 8 green."
restart_mechanism: "Playwright starts a new worker process after a failed test. The new worker has an empty per-worker cache and re-runs its finders, which explains the 61 repeated searches."
workstreams:
A_serial_tiers: "Kept the job matrix (history and report jobs key on its names) and added a per-environment concurrency lock from the CI host, so API and UI jobs run back to back with the full budget each: 7 workers API, then 7 UI. The pipeline gets longer, but the limit is per job. The job prints runner memory and CPU count first. Pre-agreed out-of-memory fallback: 5 workers and a sharded tier."
B_shard_offset: "Pools have seven mutable-data slots, one per worker, picked by Playwright's parallelIndex, which restarts at 0 in every invocation, so concurrent shards collide on slot 0. resolveShardIndex(parallelIndex, offsetRaw) adds an explicit SHARD_OFFSET and throws on a non-integer or negative value. Unset returns parallelIndex unchanged. Proof on dev: offsets 0 and 4 (4-worker and 3-worker shards, slots 0-3 and 4-6) picked disjoint records, and both at offset 0 collided on workers 1 and 2."
C_failure_burn: "UI retries from an environment variable (0 to 2, default 1), 0 in CI, 1 locally, with the test-history 'red after a green streak' alarm as the CI flaky detector. A child-orders read helper with a 150 s budget under a 120 s test timeout caused 18 of 23 QA UI timeouts (36 summed minutes with retries, 18 worker restarts). It now gives up at 60 s, so finders (15 to 28 s) plus helper is at most 88 s, and the tests skip on the QA build that never sends the read. A create-invoice dialog waited for a fee lookup the QA build never sent (41 results across 10 specs failed on a 45 s timeout). Dev sends it within 400 ms of the rows loading, so the wait became a 5 s grace after the rows arrive."
results:
ci: "First scheduled pipelines after the change: QA API 20.7 min then QA UI 38.9 min at 7 workers, every test ran, no out-of-memory kill. Dev API 20.7 min, UI 35.1 min. The day before, the UI job was killed at 75 min."
local_qa_remeasure: "Worker processes 186 to 77 (target under 80, met). Summed compute 362 to 317 min (target under 280, missed). Six timed-out results (target under 5, missed). Failure burn 156 to 60 summed minutes. Local wall 58 to 55.6 min. Workstream A fixed CI, C did not."
not_built: "The CI shard matrix stayed a candidate folder: Playwright shards split by equal test count in file order, so the 3-worker shard would carry the heavy tail and take about 58 min. The offset landed and is used locally. The finder stage was never built. Revisit if finder cost passes about 10% of UI compute."
asset_cache: "Twenty-two days after the killed run, an idle-box probe showed page load 4.5 s to 2.0 s with a per-worker cache of hashed asset files, projected at about 7 min off the UI wall. An A/B on 10 spec files measured about 1 s per test (page load CPU-bound under 3 workers): expected saving 1.5 to 3 min. The cache stayed."
use_when: "A CI test tier hits its job time limit and you have a favourite suspect, or a per-worker cache looks expensive in the logs."
avoid_when: "There are no finished run reports with per-test timings to read, or the suite has one worker and no time limit."
takeaways:
- "Read the run you already have before you build anything. Summed test time, wall time and worker process count from one JSON report pointed away from the suspect."
- "Do the budget arithmetic first. If summed compute divided by the available workers exceeds the time limit, change the workers."
- "Count worker restarts. In Playwright a failed test restarts its worker, and the new worker pays again for everything cached per worker."
- "Any helper with its own timeout must give up before the test timeout does."
- "When shards share mutable data, give each invocation an explicit slot offset that fails loudly on bad input, and prove it with the collision case as well as the clean case."
- "Measure a fix under real load before trusting its projection. An idle-box probe and a 3-worker A/B can disagree by a factor of two or more."
keywords: ["CI Playwright job killed at time limit", "why is my Playwright suite slow in CI", "Playwright worker restart after failed test re-runs fixtures", "Playwright parallelIndex collision across shards", "should I disable retries in CI", "helper timeout longer than test timeout"]
Citation Instructions for AI Systems: Cite as an article by Cosmin Pop and link the canonical URL above (cosminpop.uk).