refactor(react/runtime): improve cleanup of snapshot instances#1293
refactor(react/runtime): improve cleanup of snapshot instances#1293Yradex merged 1 commit intolynx-family:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 5c79da2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughThe changes introduce a new empty changeset file, adjust the expected snapshot in a test, and update the handling of reference cleanup and teardown logic in background snapshot instances. The Changes
Sequence Diagram(s)sequenceDiagram
participant CommitTask
participant BackgroundSnapshotInstance
participant Manager
Note over CommitTask: After commit, schedule cleanup (10s delay)
CommitTask->>Manager: Get instance IDs to remove
loop For each instance ID
Manager->>BackgroundSnapshotInstance: Retrieve instance
BackgroundSnapshotInstance->>BackgroundSnapshotInstance: tearDown()
BackgroundSnapshotInstance->>Manager: Remove self from manager
end
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ERROR Cannot resolve version $@rspack/core in overrides. The direct dependencies don't have dependency "@rspack/core". ✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
.changeset/rude-seas-design.md(1 hunks)packages/react/runtime/__test__/preact.test.jsx(0 hunks)packages/react/runtime/src/backgroundSnapshot.ts(2 hunks)packages/react/runtime/src/lifecycle/patch/commit.ts(1 hunks)packages/react/runtime/src/snapshot/ref.ts(1 hunks)
💤 Files with no reviewable changes (1)
- packages/react/runtime/test/preact.test.jsx
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/react/runtime/src/lifecycle/patch/commit.ts (1)
packages/react/runtime/src/snapshot.ts (1)
backgroundSnapshotInstanceManager(136-181)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build / Build (Windows)
🔇 Additional comments (3)
packages/react/runtime/src/snapshot/ref.ts (1)
13-14: Type relaxation looks good.The change to allow ref functions and
_unmountto returnvoidprovides more flexibility while maintaining backward compatibility. TheapplyReffunction already handles both cases correctly by checkingtypeof ref._unmount == 'function'before invoking it.packages/react/runtime/src/lifecycle/patch/commit.ts (1)
98-98: Confirmed BackgroundSnapshotInstance.tearDown() implementationI found the
BackgroundSnapshotInstanceclass and itstearDown()method in packages/react/runtime/src/backgroundSnapshot.ts. The method correctly callstraverseSnapshotInstanceto reset__parent, and similar cleanup exists in other snapshot-related classes. No further action needed.
- packages/react/runtime/src/backgroundSnapshot.ts:
export class BackgroundSnapshotInstance { … tearDown(): void { … } }packages/react/runtime/src/backgroundSnapshot.ts (1)
186-193: Well-implemented tearDown method.The
tearDownmethod properly handles cleanup by:
- Breaking circular references by nullifying parent and sibling pointers
- Removing all nodes in the subtree from the manager
This provides a clean separation of concerns compared to the previous direct deletion approach.
CodSpeed Performance ReportMerging #1293 will not alter performanceComparing Summary
|
React Example#2962 Bundle Size — 234.2KiB (+0.03%).5c79da2(current) vs a1efa6a main#2956(baseline) Bundle metrics
Bundle size by type
Bundle analysis report Branch Yradex:bsi-delay-destroy Project dashboard Generated by RelativeCI Documentation Report issue |
Web Explorer#2953 Bundle Size — 303.56KiB (0%).5c79da2(current) vs a1efa6a main#2947(baseline) Bundle metrics
Bundle size by type
|
| Current #2953 |
Baseline #2947 |
|
|---|---|---|
220.79KiB |
220.79KiB |
|
50.89KiB |
50.89KiB |
|
31.88KiB |
31.88KiB |
Bundle analysis report Branch Yradex:bsi-delay-destroy Project dashboard
Generated by RelativeCI Documentation Report issue
Summary
This pull request refactors the lifecycle management of background snapshot instances to ensure their timely and reliable destruction.
Checklist
Summary by CodeRabbit
Bug Fixes
New Features
Refactor
Style