fix: guard React transition runtime APIs - #576
cursor[bot] wants to merge 1 commit into
Conversation
Co-authored-by: theg1239 <theg1239@users.noreply.github.com>
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ❌ Deployment failed View logs |
examcooker | b5aafe5 | Sep 07 2026, 11:14 AM |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| return imports; | ||
| } | ||
|
|
||
| function assertNoUnsafeReactRuntimeImports() { |
There was a problem hiding this comment.
This guard is only run manually: no package script or workflow invokes it. Future direct imports of React APIs missing at runtime can therefore be merged and deployed without this protection running, recreating a client-side crash. This is a non-blocking maintenance concern; add the guard to an automatically run check.
Artifacts
- The authored executable command enumerates tracked manifests and workflows, then searches tracked files for a candidate invocation; it makes the absence check reproducible.
- Executed `CI=true pnpm exec tsx scripts/test-react-transition-runtime-imports.ts` in `/home/user/repo` and captured exit code 0; the standalone guard itself is runnable and passes.
- Executed the authored invocation audit in `/home/user/repo` and captured the two manifests, one workflow, no candidate references, and exit code 0; no automatic package or CI invocation exists.
| const namedImport = imported.match(/\{([\s\S]*?)\}/); | ||
| if (!namedImport) continue; |
There was a problem hiding this comment.
The guard skips React imports without named specifiers and only matches bare <ViewTransition> tags. A file using import * as React from "react" with <React.ViewTransition /> passes the guard despite directly using the unavailable runtime API. This is a non-blocking gap that makes the regression check unreliable; recognize namespace, default, and CommonJS React bindings as well.
Artifacts
- This authored shell harness creates the isolated fixture, runs the scanner before and after it, and removes the fixture on exit; it provides the exact executable repro.
- The candidate scanner was executed with no temporary fixture and exited 0 after printing its pass message; this establishes the baseline.
- The candidate scanner was executed after creating a fixture with `import * as React from 'react'` and `<React.ViewTransition />`, yet exited 0 and reported a pass; this confirms the bypass.
- A command checked that the temporary fixture no longer exists and exited 0; the fixture was cleaned up.
Bug and impact
React 19.2.8 in this repository does not export
addTransitionTypeorViewTransitionat runtime. Recent navigation/search/past-paper components imported those APIs directly fromreact, so common client paths could crash when rendering<ViewTransition>or when a navigation/search handler calledaddTransitionType(...).Root cause
The installed
@types/reactexposes canary transition APIs, but the installedreactruntime reports both exports asundefined. TypeScript/build can therefore pass while the client bundle still breaks at runtime.Fix
app/components/common/react-transition.tsxas a runtime-safe compatibility wrapper.addOptionalTransitionType(...).<ViewTransition>render sites throughOptionalViewTransition, which renders children directly when the runtime API is unavailable.scripts/test-react-transition-runtime-imports.tsto prevent direct runtime imports/rendering from coming back.Validation
CI=true corepack pnpm exec tsx scripts/test-react-transition-runtime-imports.tspasses and printsaddTransitionType=undefined ViewTransition=undefined Activity=symbol.CI=true corepack pnpm buildcompiles successfully and finishes TypeScript, then fails only during page data collection because localDATABASE_URLis unset.spent a lot of water and tokens to review your slop
Greptile Summary
The compatibility layer avoids direct use of React transition APIs that are absent at runtime. Two non-blocking maintenance gaps remain: its regression guard is not run automatically, and it can miss qualified React API access.
Confidence Score: 4/5
The reproduced issues are non-blocking guard-maintenance gaps; the compatibility implementation itself is not shown to fail in the current code.
Both confirmed findings concern incomplete regression protection rather than a currently reproduced product failure.
Files Needing Attention: scripts/test-react-transition-runtime-imports.ts should be connected to an automatically run check and expanded to recognize qualified React API access. package.json and .github/workflows/deploy-appservice.yml are the available locations for connecting the guard.
What T-Rex did
Comments Outside Diff (2)
General comment
scripts/test-react-transition-runtime-imports.tshas no invocation from either tracked package manifest or the tracked GitHub Actions workflow. Consequently, future unsafe React runtime imports can be merged and deployed without this guard executing.package.jsonscripts and.github/workflows/deploy-appservice.yml; no separate test workflow is tracked.test:react-transition-runtime-imports: tsx scripts/test-react-transition-runtime-imports.ts, then invoke it from the CI/deploy validation sequence (or a dedicated pull-request test workflow).General comment
import * as React from 'react';and<React.ViewTransition />passesscripts/test-react-transition-runtime-imports.ts. This bypasses the guard intended to prevent direct use of React's runtime ViewTransition API outside the compatibility wrapper.{...}named-import block (lines 70–71), and the JSX check only matches bare<ViewTransition>tags (line 86), not member expressions such as<React.ViewTransition>.ViewTransitionandaddTransitionType, including JSX tags such as<React.ViewTransition />and calls such asReact.addTransitionType(...).Reviews (1): Last reviewed commit: "fix: guard React transition runtime APIs" | Re-trigger Greptile
Context used: