Repository navigation
test: gate auth suites, mint without site url - #932
Conversation
📊 Performance Benchmark Results |
thinkclay
left a comment
There was a problem hiding this comment.
Good diagnosis. The CI log did say why, and "the helpers never visit the link; they only need token_hash and type" is the right conclusion — removing the dependency on site_url beats setting a dummy one.
Checked the parser:
const query = magicLink.indexOf('?')
return new URLSearchParams(query === -1 ? '' : magicLink.slice(query + 1))Correct for what GoTrue emits (…/auth/confirm?token_hash=…&type=signup): first ?, no fragment. Worth knowing it would fold a #fragment into the last param's value if one ever appeared — not a concern for confirm links, and no regression since new URL().searchParams ignored fragments anyway.
Removing the env( guard is the right call even though it deletes a diagnostic. A guard that returns null and aborts every suite is worse than parsing the two things you need. And you flagged the residual — GoTrue still builds links on the placeholder in CI, so a future test asserting where a link points will hit it. That note is doing real work; please keep it there.
One wart on the O*NET fixtures
The setup/teardown pair is a sound Deno pattern (no beforeAll), and gating on count means a stack with real O*NET data is untouched. But the cleanup is reachable only through a test that runs:
if (count) return; // setup: skip when rows exist
…
if (!seededFixtures) return; // teardown: skip when we didn't seedIf a run is killed mid-suite — timeout, OOM, Ctrl-C — the three fixture rows survive. The next run then sees count === 3, returns early, leaves seededFixtures false, and never cleans up. The rows persist until a db reset, and every later run quietly tests against them believing they are real data.
Benign, and it self-conceals, which is the part I would note in a comment at least. A cheap hardening would be deleting by onetsoc_code unconditionally in teardown rather than gating on seededFixtures — those three codes are fixtures whether or not this process inserted them. Your call; not blocking.
Approving.
… if it does not (#987) (#995) The job has reported success while producing nothing since roughly the Expo 55->56 upgrade. The comment it left on #990 was an empty code block. Three things had to be wrong for that: 1. No --config, so deno's config discovery walked out of packages/supabase into apps/ui-storybook-native/tsconfig.json and refused its `"jsx": "react-native"`. continue-on-error swallowed the exit code, and the `>` redirect still created an empty benchmark-results.txt — so the artifact and the comment were empty rather than missing, which is why nobody noticed. Any deno invocation from this repo without --config hits it; reproduced with a throwaway file in /tmp. 2. functions/api/__tests__/setup.ts:305 read `url.searchParams` after #932 replaced `new URL()` with `new URLSearchParams()` named `params`. completeMagicLinkAuth's "missing token or type" branch would have thrown a ReferenceError instead of logging and returning null. 3. It could not finish in the time the job had. Measured: 389s at the file's defaults, 180s with fewer requests per iteration — barely better, because Deno.bench keeps sampling until it is confident and simply took more samples — and 83s once the sample count itself is bounded with `n`. All four knobs are env-overridable; CI takes the bounded set, local runs keep the larger defaults. timeout-minutes 10 -> 15, since 83s is on an M4 Pro and the job also pays for checkout, install and `supabase start`. continue-on-error stays on the measurement: a slow benchmark should not block a PR. But "it ran and was slow" and "it never ran" are different states and only the first deserves to be quiet, so a new step fails the job when the results file is empty or missing. Verified with CI's env against a real stack: exit 0, 83s, 54 lines, all five summary rows carrying real figures. Not fixed here, and worth seeing before trusting the output: there are no tRPC benchmarks at all (all five are REST, so the rest-vs-trpc name has no other half), the run logs 30 auth 500s from the magic-link fixture, and the summary's "2.6 s" is one iteration of 20 requests rather than a per-request time. Co-authored-by: Claude Opus 5 <[email protected]>
Part of #926. It fixes findings 2 and 3; checking the function secrets on dev, preview and prod is the one item left.
auth, auth-session-regression, ccpa, onet and resume passed locally and failed 40 of 152 in CI, all on Failed to get or create auth token. The CI log already said why:
Magic link was built on an unsubstituted config placeholder: env%28EXPO_PUBLIC_URL%29/auth/confirm?token_hash=…&type=signup
config.toml sets site_url = "env(EXPO_PUBLIC_URL)". pnpm supa loads it from .env. CI runs plain supabase start without it, so GoTrue built every emailed link on the literal placeholder. The test helpers parsed the link with new URL(), which throws on that, so every sign-up came back null.
The helpers never visit the link; they only need token_hash and type for verifyOtp. So they now read the query string directly, and the site URL stops mattering. That avoids setting a dummy one in CI.
Changes
Verification
In CI, GoTrue still builds its emailed links on the placeholder. Nothing follows them now, but a future test that checks where a link points would hit it.