Fix high-risk React Doctor findings - #225
Conversation
Amp-Thread-ID: https://ampcode.com/threads/T-019fa8d8-de26-754f-ac71-c8a1fd1667d7 Co-authored-by: Arjun Komath <arjunkomath@gmail.com>
|
React Doctor found no issues. 🎉
|
techulus-agent
left a comment
There was a problem hiding this comment.
Review
Overview
Ten files, mostly React Doctor remediation: registering two orphaned Inngest crons, switching two SWR call sites to the shared throwing fetcher and rendering error states, wrapping three auth submit handlers in try/finally, re-keying the serverless editor, and adding aria-labels to icon-only buttons.
The highest-value change here is not a lint fix: controlPlaneUpdateCheck and agentUpgradeTimeoutCheck were exported from lib/inngest/functions but never passed to serve(), so both crons have been dead. Good catch.
Correctness
app/api/inngest/route.ts— correct; both symbols exist inlib/inngest/functions/index.tsand are now registered.replicas-section.tsx— the old inline fetcher calledres.json()unconditionally, so a 500 HTML/JSON error body would flow intoservers.map(...)and either throw inside SWR or render an empty list as "no servers available". Routing throughlib/fetcherplus the explicit errorEmptystate is the right fix, andAlertTrianglewas already imported.github-repo-selector.tsx— same class of fix. One dead condition though: inpublicRepoFromSearch,if (!error && alreadyInList)can never differ fromif (alreadyInList), because whenerroris setdatais undefined andreposisEMPTY_REPOS, makingalreadyInListalwaysfalse. Same for the!error &&guards on the two empty-state branches —hasInstallationsis alreadyfalseandfilteredReposalready empty on error. They're harmless but they read as if they're guarding something. I'd droperrorfrom theuseMemodeps and the guards, keeping only the newrole="alert"block.isLoading && !data— redundant: SWR'sisLoadingis already!data && !error. Not wrong, just noise.- Auth pages —
try/catch/finallycorrectly guarantees the button un-sticks on a rejected promise. Behaviour on the success andtwoFactorRedirectpaths is unchanged (setLoading(false)ran before therouter.pushpreviously too). Swallowing the exception and showing a generic message is the right call for auth surfaces; no info leak. serverless-section.tsx— splitting into a keyed inner editor withkeepMountedonConfigSectionis a sound way to reset drafts without collapsing the section, and matches the existingkeepMountedusage innetworking-section.tsx. Worth being explicit that this means an in-flight unsaved edit is discarded the moment a refresh changes any of the four keyed fields; that's the intended semantics, but it's the kind of thing that deserves a one-line comment next tosettingsKeyrather than only on theuseState.
Test coverage
tests/inngest-route.test.ts guards the specific regression, but only the specific one. Because the whole @/lib/inngest/functions module is replaced by a hand-maintained object, the next function that gets exported and not registered will slip through exactly the same way — the mock simply won't have it, route.ts will import undefined, and arrayContaining on two unrelated entries still passes.
Stronger and less maintenance for the same effort: mock the module but assert the registered array covers every mocked export, e.g.
expect(options?.functions).toEqual(
expect.arrayContaining(Object.values(mocks.functions)),
);
expect(options?.functions).toHaveLength(Object.keys(mocks.functions).length);That turns the hand-maintained list into the contract instead of a prop, and fails loudly when route.ts drifts.
Style / conventions
Consistent with the codebase — tabs, memo retained, shared fetcher reused rather than re-inlined. The oxlint-disable-next-line carries a real justification, which is the right way to use one.
Security & performance
Nothing concerning. lib/fetcher uses cache: "no-store", so the replicas/repos requests are no longer subject to whatever default caching fetch applied — that's a behavioural change in the right direction for these endpoints, but flagging it since it wasn't in the summary. keepMounted on the serverless section means the editor mounts even while collapsed; it's a handful of useStates, negligible.
Verdict
Approve with minor follow-ups: drop the no-op error guards in the repo selector, and consider tightening the Inngest route test so it catches the next unregistered function rather than only these two.
Amp-Thread-ID: https://ampcode.com/threads/T-019fa8d8-de26-754f-ac71-c8a1fd1667d7 Co-authored-by: Arjun Komath <arjunkomath@gmail.com>
|
Arjun addressed the review feedback in c119375:
The Focused test, TypeScript, and Biome checks pass. |
Summary
React Doctor 0.9.2 warnings dropped from 147 to 135. The remaining findings are lower-risk heuristics or require separate performance/design work.
Validation
pnpm test— 46 files, 307 tests passedtsc --noEmitbiome checkon changed filesOut of scope
The pnpm
trustPolicywarning was not changed: enablingno-downgraderejects four existing lockfile entries, so that hardening needs a separate dependency provenance review rather than a lint-driven lockfile rewrite.