From 12c3dda7cf84544e2bd71bc4037395d5ee0580e0 Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Wed, 11 Nov 2026 12:50:16 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20test:=20Let=20Theme=20Paint=20Ro?= =?UTF-8?q?ute=20Handlers=20Settle=20Before=20Teardown=20(#18059)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "the ClickHouse theme paints its own link, code fill and QR backdrop" and "a theme that names only its link colours Markdown links in both modes and can recolour the QR backdrop" each failed a first attempt in 1 of 70 pull request runs on Nov 11 with "apiResponse.json: Response has been disposed", thrown from the `/api/config` route handler after every assertion had passed. The app requests `/api/config` three times while it starts, the third about 90ms after the first two. Both tests end within a few milliseconds of that request, so it can still be inside `serveThemes` when the body returns: in one CI trace the handler's fetch starts 1ms before the last assertion and finishes 10ms after the context began closing. Closing the context disposes the fetched response, `response.json()` throws, and Playwright reports the handler's error against the finished test. Every test in the file now waits for its route handlers to finish before the context is torn down. A handler that throws for any other reason is still reported; only the race against teardown is gone. --- e2e/specs/mock/scenarios/theme-paint.spec.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/e2e/specs/mock/scenarios/theme-paint.spec.ts b/e2e/specs/mock/scenarios/theme-paint.spec.ts index 150ad5faed..c47447bef6 100644 --- a/e2e/specs/mock/scenarios/theme-paint.spec.ts +++ b/e2e/specs/mock/scenarios/theme-paint.spec.ts @@ -152,6 +152,16 @@ function paintRoles(page: Page) { const rgb = (channels: string | undefined) => `rgb(${(channels ?? '').split(' ').join(', ')})`; test.describe('controlled theme paint', () => { + /** + * The app asks for `/api/config` again once the session resolves, and that request can still be + * inside a `serveThemes` handler when a test body returns. Closing the context under it disposes + * the fetched response, which fails the finished test from the handler, so each test lets its + * handlers settle first. + */ + test.afterEach(async ({ page }) => { + await page.unrouteAll({ behavior: 'wait' }); + }); + test("a shared link's first frame of the conversation already wears the link tenant's theme @scenario:shared-link-first-frame-wears-link-theme", async ({ page, }) => {