Skip to content

FPFNFIXAPEX: preserve scalar cancellation guards across while iterations - #2202

Draft
aidenybai wants to merge 2 commits into
fix/next-query-state-snapshotfrom
fix/async-while-cancellation-flow
Draft

aidenybai wants to merge 2 commits into
fix/next-query-state-snapshotfrom
fix/async-while-cancellation-flow

Conversation

@aidenybai

@aidenybai aidenybai commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Why

no-set-state-after-await-in-effect flattened while bodies. It warned on cancellation checks after each await and missed writes reached after an earlier iteration suspended.

The review also found repeated traversal of nested loops and scalar writes. Reuse pure Program facts and supported-subtree facts, then memoize flow results by the full analysis inputs and node identities.

What changed

  • Analyze supported loops until path states stop changing. Preserve zero-iteration exits, recheck conditions and discard branch exclusivity from earlier iterations.
  • Accept scalar Boolean guards only when their writes preserve cancellation. Keep the existing fallback for ref/sequence guards and unsupported control flow.
  • Cache scalar writes, structural support and flow results for the actual context, scopes and Program. Clone cached path states and retain identity checks.
  • Add native growth and same-AST differential controls alongside the regression tests, fuzz seeds and patch changeset. Stacked on FPFNFIXAPEX: preserve native Next query state snapshots #2201.

The single-countdown false warning discovered in this PR is corrected by #2203. The previously documented erased-eval and outer-cancellation-reset controls retain their original results; this repair receives no fix credit for them.

Test plan

  • Focused performance controls: 39 passed; package typecheck passed.
  • 491 old/new full diagnostic comparisons preserve results and AST properties and references.
  • Full seven-package suite: 35,691 passed, 1,119 skipped.
  • All package typechecks, lint, format, registry, published-dependency checks and JSON schema smoke passed. Fresh build: five successful tasks, no cache hits; 175 own runtime artifacts and five package edges verified.
  • Strict fuzzing: 500 iterations, seed 42; 2,154 executions, 235 target firings, no findings.
  • Native growth controls cover nested loop traversal and the moved scalar-write scan. Operation counts are separate from CPU/wall-time profiling.
  • Normal hooks ran. A physical five-path staged scan reproduced one js-set-map-lookups warning in collectCleanupFunctionsAfterInvocations. The entire function and reporting rule are byte-identical before this PR, in the published PR and after the repair. No suppression was added.
  • React Doctor CI and one commit-preview workflow passed on the pushed repair. A duplicate preview workflow failed at the external pkg-pr-new /check endpoint with HTTP 404 after its automatic retries; no workflow rerun was requested.

This PR remains draft pending integration of the updated ancestor fixes, final composed-source checks, public performance profiles and remote parity. Earlier performance flags remain unresolved.

@pkg-pr-new

pkg-pr-new Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/eslint-plugin-react-doctor@2202
npm i https://pkg.pr.new/oxlint-plugin-react-doctor@2202
npm i https://pkg.pr.new/react-doctor@2202

commit: df6270b

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant