From e4794610bc939306eed8754b2192a05e9dd32981 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Sat, 5 Dec 2026 14:46:55 +0000 Subject: [PATCH 1/2] Journeys: the sign-in callback's GitHub-call count leaves out the browser's own authorize request (sc-9611) Run 47531375940 failed a docs-only PR: GET /login/oauth/authorize, which the browser makes just before the callback, fell inside the callback's time window on a busy runner and counted as a fourth call. The callback is also matched by its path, not by any URL containing it. --- scripts/screenshots/journeys.mjs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/screenshots/journeys.mjs b/scripts/screenshots/journeys.mjs index d478331f..9cd251e6 100644 --- a/scripts/screenshots/journeys.mjs +++ b/scripts/screenshots/journeys.mjs @@ -538,8 +538,10 @@ await journey('sign-in-redirects-at-once-and-lists-after', async ({ page, shot } await stub(page, '/_stub/requests/clear') let asked = 0 let answered = 0 - const onRequest = (r) => r.url().includes('/auth/github/callback') && (asked = Date.now()) - const onResponse = (r) => r.url().includes('/auth/github/callback') && (answered = Date.now()) + // The callback itself, by its path: not another URL that mentions it (the authorize URL's redirect_uri) + const isCallback = (url) => new URL(url).pathname === '/auth/github/callback' + const onRequest = (r) => isCallback(r.url()) && (asked = Date.now()) + const onResponse = (r) => isCallback(r.url()) && (answered = Date.now()) page.on('request', onRequest) page.on('response', onResponse) await signInFromSite(page, shot, 'site-github-slow') @@ -551,7 +553,11 @@ await journey('sign-in-redirects-at-once-and-lists-after', async ({ page, shot } // little more. The listing alone takes 8 s here, so a callback that waited for it fails either way expect(ms < 1500, `the sign-in callback took ${ms} ms`) const timed = await (await page.request.get(`${GITHUB}/_stub/timed`)).json() - const inCallback = timed.filter((c) => c.started >= asked && c.finished !== null && c.finished <= answered).map((c) => c.call) + // The server's calls only: the browser's own GET /login/oauth/authorize comes just before the callback, and on a busy + // runner its times can fall inside the window (5 Dec 2026, run 47531375940 counted it as a fourth call) + const inCallback = timed + .filter((c) => c.call !== 'GET /login/oauth/authorize' && c.started >= asked && c.finished !== null && c.finished <= answered) + .map((c) => c.call) expect(inCallback.length <= 3, `the sign-in callback made ${inCallback.length} GitHub calls: ${inCallback.join(', ')}`) // An installation set up meanwhile waits on the listing: the page that loads itself again every second, served once From a93ce284f23ee4e1283ea5237e71c37f101fb3d3 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Sat, 5 Dec 2026 14:58:41 +0000 Subject: [PATCH 2/2] Journeys: count the callback's GitHub calls by order after the authorize request, not by a window from the browser's timestamp (sc-9611) --- scripts/screenshots/journeys.mjs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/scripts/screenshots/journeys.mjs b/scripts/screenshots/journeys.mjs index 9cd251e6..99a027fe 100644 --- a/scripts/screenshots/journeys.mjs +++ b/scripts/screenshots/journeys.mjs @@ -538,10 +538,8 @@ await journey('sign-in-redirects-at-once-and-lists-after', async ({ page, shot } await stub(page, '/_stub/requests/clear') let asked = 0 let answered = 0 - // The callback itself, by its path: not another URL that mentions it (the authorize URL's redirect_uri) - const isCallback = (url) => new URL(url).pathname === '/auth/github/callback' - const onRequest = (r) => isCallback(r.url()) && (asked = Date.now()) - const onResponse = (r) => isCallback(r.url()) && (answered = Date.now()) + const onRequest = (r) => r.url().includes('/auth/github/callback') && (asked = Date.now()) + const onResponse = (r) => r.url().includes('/auth/github/callback') && (answered = Date.now()) page.on('request', onRequest) page.on('response', onResponse) await signInFromSite(page, shot, 'site-github-slow') @@ -553,10 +551,15 @@ await journey('sign-in-redirects-at-once-and-lists-after', async ({ page, shot } // little more. The listing alone takes 8 s here, so a callback that waited for it fails either way expect(ms < 1500, `the sign-in callback took ${ms} ms`) const timed = await (await page.request.get(`${GITHUB}/_stub/timed`)).json() - // The server's calls only: the browser's own GET /login/oauth/authorize comes just before the callback, and on a busy - // runner its times can fall inside the window (5 Dec 2026, run 47531375940 counted it as a fourth call) + // The callback's calls are the stub's calls after the browser's own GET /login/oauth/authorize (which sends it to the + // callback) that finished before the callback answered: counted by order, not from `asked`. Both clocks are whole + // milliseconds and the browser's events reach this process late, so a window from `asked` both took in authorize + // (5 Dec 2026, run 47531375940: "4 GitHub calls") and could leave out the callback's first call + const from = timed.findLastIndex((c) => c.call === 'GET /login/oauth/authorize') + expect(from >= 0, 'the stub never saw the sign-in authorize request') const inCallback = timed - .filter((c) => c.call !== 'GET /login/oauth/authorize' && c.started >= asked && c.finished !== null && c.finished <= answered) + .slice(from + 1) + .filter((c) => c.finished !== null && c.finished <= answered) .map((c) => c.call) expect(inCallback.length <= 3, `the sign-in callback made ${inCallback.length} GitHub calls: ${inCallback.join(', ')}`)