Repository navigation
fix(ci): stop the edge-fn type ratchet answering differently on a warm cache (#969) - #973
Merged
Merged
Conversation
…m cache (#969) The gate was green in CI and red locally on the same commit. My own diagnosis in #969 was wrong: the zod TS2353 at teams.router.ts:2478 was always visible to CI and was what that file's baseline of 1 accounted for. Nothing was hidden. The flapping diagnostic is TS2589, "type instantiation is excessively deep". It fires when the checker exhausts its instantiation budget, and the budget left depends on what is already in the type cache — so the answer depends on DENO_DIR warmth. Measured on 1a735c9, same worktree, same minute, trpc only: warm 11 errors (824 TS2589 + 2478 TS2353), cold 10 (2478 only). Nothing else differed. TS2589 is now excluded from the counted diagnostics and printed on its own advisory line. A signal that cannot be reproduced cannot be ratcheted; "may only come down" means nothing if the number depends on cache state. The cost — a genuinely new deep instantiation no longer fails this gate — is written into the script. That exposed a second flapping file: api/routes/user-profiles.ts carries one too, so api had been oscillating 333/334 independently of trpc. The real bug underneath is fixed as well. z.date({ message }) is zod 4 syntax; every edge-function import map pins npm:[email protected], where the unknown key is ignored, so that validation message never reached a caller. invalid_type_error is the 3.x spelling. teams.router.ts drops to zero and leaves the baseline. Baseline tightened, never raised: user-profiles.ts 12 -> 11, teams.router.ts removed. 378 total, down from 380. Verified by running warm and with a fresh DENO_DIR on this branch: every counted number identical, both exit 0, and the only difference between the runs is the advisory line itself. Also adds packages/supabase/seeds/** to the api-tests path filters. That job seeds its stack from seeds/*.sql, so a broken seed reddens every suite in it, yet a seed-only change could not trigger the workflow at all — #972 got two skipped checks and a pending status, which reads as "nothing to see" rather than "nothing ran". Same class of bug, one line. Co-Authored-By: Claude Opus 5 <[email protected]>
Contributor
📊 Performance Benchmark Results |
Contributor
Author
|
CI green: 11 pass, 4 skipping, none red. Including Edge function types, which is the point of the PR — and its log confirms the fix with CI as a third data point rather than two local runs:
Every gated number identical across all three. The advisory count differs exactly as predicted — CI gets a fresh runner cache, so it sees the same single TS2589 a cold local run does, while a warm local cache sees two. That is the nondeterminism, now somewhere it cannot change the verdict. Before this PR the same three runs would have disagreed: warm local said |
4 tasks
This was referenced Oct 5, 2026
thinkclay
added a commit
that referenced
this pull request
Oct 5, 2026
…ng red (#986) (#990) A pull request from a fork gets a read-only GITHUB_TOKEN regardless of the `permissions: pull-requests: write` at the top of the workflow, so `github.rest.issues.createComment` throws "Resource not accessible by integration". With no guard and no continue-on-error that took the whole benchmark job down, and with it REST API Tests — every fork PR red for a step that only posts a comment. #972 surfaced it: a four-line SQL seed from an outside contributor, its own Run API Tests green, workflow red. Step outcomes for the same job on a fork (#972) and a same-repo branch (#973) differ in exactly one place, the comment step. Skipped rather than tolerated. continue-on-error would also stop it failing the build, but silently, and a step that cannot work on forks should say so. Upload Benchmark Results keeps the figures either way. Swept the other workflows for the same shape and this was the only one: dependabot-automerge is pull_request_target (base-repo token), apple-secret-rotate is workflow_dispatch, codecov already carries fail_ci_if_error: false and posts through its own app, and the lighthouse action is label-triggered with no githubToken. Verified the expression against both context shapes GitHub will supply: runs for a same-repo PR, skips for a fork. This branch is same-repo, so its own run exercises only the runs path; the skip path gets its real test on the next fork contribution, and the step being skipped is the one that was failing. Does not touch #987 — the benchmark this posts has never produced any output, which needs its own decision. Co-authored-by: Claude Opus 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #969.
The diagnosis in #969 was wrong, and the real cause is more interesting
I filed that issue claiming CI could not see a real type error. That was incorrect, and worth saying plainly: the zod
TS2353atteams.router.ts:2478is visible to CI and is what the baseline's allowed1for that file accounted for. Nothing was hidden.The flapping diagnostic is
TS2589: Type instantiation is excessively deep and possibly infinite. It is not a property of the code alone — it fires when the checker exhausts its instantiation budget, and how much budget is left depends on what is already in the type cache. So the answer depends on how warmDENO_DIRis.Measured on
1a735c9cc, same worktree, same minute,trpconly:teams.router.tssitesDENO_DIR)824TS2589 +2478TS2353DENO_DIR=$(mktemp -d))2478TS2353 onlyNothing else differed. Warm exceeded the baseline, cold matched it. CI runs on a fresh runner cache; my machine does not. Same commit, two verdicts.
What this changes
TS2589is split out of the counted diagnostics and reported on its own line. A signal that cannot be reproduced cannot be ratcheted — "may only come down" is meaningless if the number depends on cache state. The cost is stated in the script rather than left implicit: a genuinely new excessively-deep instantiation will no longer fail this gate, it will appear in the advisory line instead.Doing this immediately exposed a second flapping file nobody knew about:
api/routes/user-profiles.tsalso carries a TS2589, soapihad been oscillating between 333 and 334 independently oftrpc. Both are now quarantined.The real bug underneath
z.date({ message: … })is zod 4 syntax. Every edge-function import map pinsnpm:[email protected](functions/trpc/deno.json,functions/api/deno.json,functions/import_map.json), and a top-levelmessageparam only arrived in zod 4. On 3.x the unknown key is ignored, so that custom validation message never reached a caller —invalid_type_erroris the 3.x spelling. Quiet, but real, and in a deployed function.With it fixed,
teams.router.tsdrops to zero and leaves the baseline entirely.Baseline tightened, not raised
api/routes/user-profiles.ts: 12 → 11trpc/routers/teams.router.ts: removed (was 1)Total 378, down from 380.
Verification — the acceptance criterion, demonstrated
#969 asked for the same per-file counts locally and in CI. Run twice on this branch, warm and with a fresh
DENO_DIR:Every counted number identical, both exit 0. The only difference between the two runs is the advisory line — warm lists 2 TS2589s, cold lists 1 — which is the nondeterminism itself, now somewhere it cannot change the verdict. That is a better demonstration than identical output would have been: the flakiness is still there and is provably quarantined.
I also checked a hazard this could have introduced.
background-checks.router.ts:1824carries a@ts-expect-errorfor this exact "excessively deep" error; had a cold cache stopped producing the TS2589 there, the directive would have become unused —TS2578, which is stable and counted, and would have pushed that file WORSE. Neither run produces a TS2578, so it still triggers in both states. Worth knowing it is a latent trap: a@ts-expect-errorsuppressing a nondeterministic diagnostic is itself nondeterministic, and@ts-ignorewould be the safer spelling there.One unrelated line, and why it is here
.github/workflows/api-tests.ymlgainspackages/supabase/seeds/**in both path filters.The stack that job builds seeds itself from
seeds/*.sql(config.toml [db.seed]), so a broken seed reddens every suite in it — yet a seed-only change could not trigger the workflow at all. #972 is the live example: two skipped checks, apendingcombined status, and nothing run, which reads as "nothing to see" rather than "nothing ran". Same class of bug as this PR (a gate that is not checking what people believe it checks), and one line, so it travels with it rather than waiting.🤖 Generated with Claude Code