Skip to content

test(react-grab): cover freeze-updates replay order and recovery arms - #507

Closed
aidenybai wants to merge 1 commit into
mainfrom
test/freeze-updates-replay-recovery
Closed

test(react-grab): cover freeze-updates replay order and recovery arms#507
aidenybai wants to merge 1 commit into
mainfrom
test/freeze-updates-replay-recovery

Conversation

@aidenybai

@aidenybai aidenybai commented Jun 29, 2026

Copy link
Copy Markdown
Owner

Summary

freeze-updates.ts — the internal-dispatcher freeze/replay path, flagged as the top fragile-internals gap (65% lines, depth-weighted 42%, an unreached depth-7 block) — had zero unit coverage. This mocks bippy's fiber/renderer surface and the recoverable-error logger to drive the real exported freezeUpdates end-to-end:

  • Hook-queue buffering: pending reads are masked to null while frozen; on resume every buffered update replays in chain order. Three writes during the freeze exercise all four mergePendingChains arms ((null, single), (single, single), (multi, multi)) and the resulting circular chain is asserted to extract as ["a","b","c","d"] — proving the merge produces a complete, walkable loop. Also covers the pre-existing pending chain captured at freeze time.
  • Context-dependency freezing: value masked to the frozen snapshot while paused; buffered write applied on resume.
  • Dispatcher replay order: store callbacks → transitions → state updates.
  • Recovery arms (try/catch): a throwing buffered update is swallowed + logged ("Callback failed during state replay") and replay continues; a scheduleUpdate throw in the post-resume microtask flush is swallowed + logged ("scheduleUpdate failed during unfreeze").
  • Lifecycle guards: re-freeze while frozen and double-resume are no-ops.

The bippy mock is scoped to this file (vitest isolates module mocks per file), so other suites are unaffected.

Test plan

  • vp test run tests — 65 unit tests pass (7 in this file)
  • pnpm typecheck clean
  • pnpm lint clean

Note

Low Risk
Test-only change with no production code modifications; mocks are isolated to the new test file.

Overview
Adds freeze-updates.test.ts, the first unit coverage for freezeUpdates, using file-scoped mocks of bippy (fiber roots, renderers, composite fibers) and logRecoverableError so React internals can be exercised in Node without a real renderer.

The suite drives the real export through lifecycle (nested freeze and double-resume are safe), hook-queue buffering (masked pending while frozen; replay in chain order, including pre-freeze pending and merged writes), context dependency masking until resume, dispatcher replay order (store → transition → state), and recovery (throwing replay continues with logging; scheduleUpdate failures in the post-resume microtask are logged).

Reviewed by Cursor Bugbot for commit dce3de1. Bugbot is set up for automated code reviews on this repo. Configure here.


Summary by cubic

Add end-to-end tests for freezeUpdates to cover freeze/replay behavior, dispatcher replay order, and error recovery. The suite mocks bippy and the recoverable-error logger to verify hook-queue buffering (merge paths and pre-existing chains), context value masking, lifecycle guards, and logging when callbacks or scheduleUpdate throw.

Written for commit dce3de1. Summary will update on new commits.

Review in cubic

freeze-updates.ts (the dispatcher-patch freeze/replay path, the report's
top fragile-internals gap) had no unit coverage. Mock bippy's fiber/renderer
surface and the recoverable-error logger to drive the real freezeUpdates
end-to-end:

- hook-queue buffering: reads masked to null while frozen, every buffered
  update replayed in chain order on resume (exercises all four
  mergePendingChains arms via single/single and multi/multi merges), plus
  the pre-existing pending chain captured at freeze time.
- context-dependency freezing: value masked while frozen, buffered write
  applied on resume.
- dispatcher replay order: store callbacks -> transitions -> state updates.
- recovery: a throwing buffered update is swallowed/logged and replay
  continues; a scheduleUpdate failure in the post-resume microtask flush is
  swallowed/logged.
- lifecycle guards: re-freeze and double-resume are no-ops.
@vercel

vercel Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
react-grab-storybook Ready Ready Preview, Comment Jun 29, 2026 3:33am
react-grab-website Ready Ready Preview, Comment Jun 29, 2026 3:33am

@pkg-pr-new

pkg-pr-new Bot commented Jun 29, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@react-grab/cli@507
npm i https://pkg.pr.new/grab@507
npm i https://pkg.pr.new/react-grab@507

commit: dce3de1

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

@aidenybai

Copy link
Copy Markdown
Owner Author

Superseded by #510, which consolidates all the test-coverage PRs into one. Commits preserved there.

@aidenybai aidenybai closed this Jun 29, 2026
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