fix(template): process-scope cloneWorkerDatabase memo for Jest setupFiles - #31
Conversation
|
Warning Review limit reached
Next review available in: 42 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughSummary by CodeRabbit
WalkthroughChangesClone database naming
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/adapters/template-mode.ts`:
- Around line 81-93: Make unnamed clone names collision-resistant across module
reloads while generating one default name per module load for stable
memoization: update defaultCloneWorkerName/resolveWorkerName and clear the
retained name when cloning fails. Update tests/template-mode.test.ts:174-182 to
cover identical timestamps or a frozen clock, and
tests/template-mode.test.ts:211-238 to verify unnamed calls at different times
reuse the same memoized operation. Align the uniqueness and memoization
statements in src/adapters/template-mode.ts:68-75 and 99-106, CHANGELOG.md:5-7,
and src/adapters/jest-template.ts:23-28 with the corrected guarantee.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 491505d6-cfc1-4816-9ab4-3928eee966e8
📒 Files selected for processing (4)
CHANGELOG.mdsrc/adapters/jest-template.tssrc/adapters/template-mode.tstests/template-mode.test.ts
…ule load Unnamed cloneWorkerDatabase calls regenerated Date.now() each time, so a second call in a later ms threw instead of hitting process memo; entropy also avoids same-ms collisions across Jest setupFiles reloads.
Module-scoped memo died under Jest setupFiles reloads, causing duplicate clones on the same worker id. Store the memo on globalThis and keep boring worker-id defaults instead of unique-per-reload names.
Summary
cloneWorkerDatabaseprocess-once memo onglobalThis(Symbol.for) so it survives JestsetupFilesmodule reloads.JEST_WORKER_ID/VITEST_POOL_ID/ pid) — one clone per worker, not one per file.Test plan
vp test tests/template-mode.test.ts(includes reload-survival case)vp check