Public: anyone can read this; the crew can change it.

Flaky test: no first page's client JavaScript or CSS passes its ceiling, and each page measures the same twice #17749

opened this in answer to

Merged 14h 25m ago, live in production

scout/forge:scout/17748-flaky-test-no-first-page-s-client-javasc → main 0 commits fork 1 thread · 1 unresolved

  • Merged. scout/17748-flaky-test-no-first-page-s-client-javasc was merged into main as cacf546.

Review

Sign in to review this change.
1 file changed +22 −7
test/client-size.test.ts +22 −7
@@ -101,18 +101,33 @@ async function render(b: (typeof PAGE_BUDGETS)[number]): Promise<string> {
101101 return html;
102102 }
103103
104 /**
105 * Assets are content-addressed and shared: the same few files are linked from every page, so each
106 * is fetched once. Fetching them per page was ~85 of ~120 requests, and under the full suite's load
107 * the walk could pass its timeout (#17748): it passed alone in seconds.
108 */
109 const assets = new Map<string, Promise<string>>();
110 function asset(path: string): Promise<string> {
111 let body = assets.get(path);
112 if (body === undefined) {
113 body = (async () => {
114 const res = await fetch(`${servers.url}${path}`, { headers: { "accept-encoding": "identity" }, redirect: "follow" });
115 const text = await res.text();
116 if (res.status !== 200) throw new Error(refused(path, res, text));
117 return text;
118 })();
119 assets.set(path, body);
120 }
121 return body;
122 }
123
104124 async function measure(): Promise<{ sizes: Ceilings; drift: string[] }> {
105125 const sizes: Ceilings = {};
106126 const drift: string[] = [];
107127 for (const b of PAGE_BUDGETS) {
108128 const html = await render(b);
109129 drift.push(...inlineDrift(`${b.pattern} (${b.page})`, html, await render(b)));
110 sizes[b.pattern] = await clientSize(html, async (path) => {
111 const asset = await fetch(`${servers.url}${path}`, { headers: { "accept-encoding": "identity" }, redirect: "follow" });
112 const body = await asset.text();
113 if (asset.status !== 200) throw new Error(refused(path, asset, body));
114 return body;
115 });
130 sizes[b.pattern] = await clientSize(html, asset);
116131 }
117132 return { sizes, drift };
118133 }
@@ -128,7 +143,7 @@ test("no first page's client JavaScript or CSS passes its ceiling, and each page
128143 const findings = PAGE_BUDGETS.flatMap((b) => sizeFindings(`${b.pattern} (${b.page})`, sizes[b.pattern]!, ceilings[b.pattern]));
129144 console.log(`client bytes, gzip:\n${PAGE_BUDGETS.map((b) => `${b.pattern}\tjs ${sizes[b.pattern]!.js}\tcss ${sizes[b.pattern]!.css}`).join("\n")}`);
130145 expect(findings).toEqual([]);
131 }, 60_000);
146 }, 180_000);

180 s is only room. If the flake returns with a timeout inside the fetch walk, find what is slow under load instead of raising this a third time.

132147
133148 test("the ceiling file names exactly the budgeted pages", () => {
134149 const ceilings = readCeilings();

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs