Skip to content

Conversation

@Yradex
Copy link
Collaborator

@Yradex Yradex commented Sep 15, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Improved stability during main-thread reloads, reducing potential errors or interruptions.
    • Optimized background behavior to avoid unnecessary initialization, enhancing performance consistency.
  • Chores

    • Added a metadata file for release management; no user-facing changes.

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).
  • Changeset added, and when a BREAKING CHANGE occurs, it needs to be clearly marked (or not required).

@Yradex Yradex requested a review from hzy as a code owner September 15, 2025 11:59
@changeset-bot
Copy link

changeset-bot bot commented Sep 15, 2025

🦋 Changeset detected

Latest commit: 91ce14c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When 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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 15, 2025

📝 Walkthrough

Walkthrough

Removes the main-thread call to destroyWorklet during reload and gates an initialization patch inside destroyWorklet behind a BACKGROUND check. Adds a new empty changeset metadata file. No public API or type signatures changed.

Changes

Cohort / File(s) Summary
Changeset metadata
\.changeset/every-tools-reply.md
Added a new file containing only a YAML front matter block with no content; no code paths affected.
Runtime reload/worklet lifecycle
packages/react/runtime/src/lifecycle/reload.ts, packages/react/runtime/src/worklet/destroy.ts
reload.ts: removed destroyWorklet import and its invocation in reloadMainThread.
destroy.ts: gated takeWorkletRefInitValuePatch() behind if (__BACKGROUND__); other logic unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

framework:React

Suggested reviewers

  • hzy
  • colinaaa

Poem

I twitch my whiskers, press reload—no fuss, no fret, no sprawl.
The worklet naps in backgrounds deep, obeying one small call.
A YAML leaf falls soft and light, no code is stirred at all.
Hop hop! The stack stays sleek tonight—
🐇 minimal changes, standing tall.

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Pre-merge checks

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "fix(react/runtime): remove useless function calls" accurately and concisely describes the primary change set by indicating removal of internal function calls within the react/runtime package (for example, removal of destroyWorklet() from reloadMainThread and gating takeWorkletRefInitValuePatch()). It is short, focused, and informative enough for a reviewer scanning history to understand the main intent.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

@codecov
Copy link

codecov bot commented Sep 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/react/runtime/src/worklet/destroy.ts (2)

14-17: Make teardown resilient: run all tasks even if one throws and clear queue up-front.

Pre-clearing and per-task try/catch avoids partial teardown and ensures the queue is emptied even on errors.

Apply:

-  for (const task of destroyTasks) {
-    task();
-  }
-  destroyTasks.length = 0;
+  // Empty the queue first; new tasks scheduled during teardown run on a future cycle.
+  const tasks = destroyTasks.splice(0);
+  for (const task of tasks) {
+    try {
+      task();
+    } catch {
+      // Best-effort teardown: swallow to continue destroying remaining tasks.
+      // Hook up logging here if desired.
+    }
+  }

10-12: Main-thread commit already flushes init patches; add clarifying comment

packages/react/runtime/src/lifecycle/patch/commit.ts calls takeWorkletRefInitValuePatch() (around line 142) and workletRefPool clears the patch (packages/react/runtime/src/worklet/workletRefPool.ts:25–27), so main-thread reloads won't accumulate stale init patches. Keep the background-only gating in destroy.ts but add the one-line comment to document intent.

 export function destroyWorklet(): void {
-  if (__BACKGROUND__) {
+  // Background-only: flushing init-value patch is safe/needed only during background reloads.
+  if (__BACKGROUND__) {
     takeWorkletRefInitValuePatch();
   }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1a720e0 and 91ce14c.

📒 Files selected for processing (3)
  • .changeset/every-tools-reply.md (1 hunks)
  • packages/react/runtime/src/lifecycle/reload.ts (0 hunks)
  • packages/react/runtime/src/worklet/destroy.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • packages/react/runtime/src/lifecycle/reload.ts
🧰 Additional context used
📓 Path-based instructions (1)
.changeset/*.md

📄 CodeRabbit inference engine (AGENTS.md)

For contributions, always generate a changeset and commit the resulting markdown file(s)

Files:

  • .changeset/every-tools-reply.md
🧠 Learnings (1)
📚 Learning: 2025-09-12T09:43:04.810Z
Learnt from: gaoachao
PR: lynx-family/lynx-stack#1736
File: .changeset/spotty-experts-smoke.md:1-3
Timestamp: 2025-09-12T09:43:04.810Z
Learning: In the lynx-family/lynx-stack repository, empty changeset files (containing only `---\n\n---`) are used for internal changes that modify src/** files but don't require meaningful release notes, such as private package changes or testing-only modifications. This satisfies CI requirements without generating user-facing release notes.

Applied to files:

  • .changeset/every-tools-reply.md
🧬 Code graph analysis (1)
packages/react/runtime/src/worklet/destroy.ts (1)
packages/react/runtime/src/worklet/workletRefPool.ts (1)
  • takeWorkletRefInitValuePatch (25-29)
⏰ 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). (3)
  • GitHub Check: build / Build (Windows)
  • GitHub Check: build / Build (Ubuntu)
  • GitHub Check: test-rust / Test (Ubuntu)
🔇 Additional comments (1)
.changeset/every-tools-reply.md (1)

1-3: Empty changeset matches repo convention; keep as-is.

Using retrieved learnings: this ---/blank/--- changeset is the accepted pattern here for internal src/** tweaks with no user-facing notes. Looks good.

Please confirm CI passes the changeset check on this PR.

@relativeci
Copy link

relativeci bot commented Sep 15, 2025

Web Explorer

#5222 Bundle Size — 364.39KiB (0%).

91ce14c(current) vs 1a720e0 main#5220(baseline)

Bundle metrics  Change 1 change
                 Current
#5222
     Baseline
#5220
No change  Initial JS 145.41KiB 145.41KiB
No change  Initial CSS 31.89KiB 31.89KiB
No change  Cache Invalidation 0% 0%
No change  Chunks 8 8
No change  Assets 8 8
Change  Modules 220(+0.92%) 218
No change  Duplicate Modules 16 16
No change  Duplicate Code 3.37% 3.37%
No change  Packages 4 4
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#5222
     Baseline
#5220
No change  JS 238.48KiB 238.48KiB
No change  Other 94.02KiB 94.02KiB
No change  CSS 31.89KiB 31.89KiB

Bundle analysis reportBranch Yradex:fix/mtf-reload3Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link

relativeci bot commented Sep 15, 2025

React Example

#5229 Bundle Size — 238.76KiB (-0.06%).

91ce14c(current) vs 1a720e0 main#5227(baseline)

Bundle metrics  Change 4 changes Improvement 1 improvement
                 Current
#5229
     Baseline
#5227
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
Change  Cache Invalidation 38.99% 0%
No change  Chunks 0 0
No change  Assets 4 4
Change  Modules 162(-1.22%) 164
Improvement  Duplicate Modules 65(-2.99%) 67
Change  Duplicate Code 46.71%(-0.15%) 46.78%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  Change 1 change Improvement 1 improvement
                 Current
#5229
     Baseline
#5227
No change  IMG 145.76KiB 145.76KiB
Improvement  Other 93KiB (-0.15%) 93.14KiB

Bundle analysis reportBranch Yradex:fix/mtf-reload3Project dashboard


Generated by RelativeCIDocumentationReport issue

@Yradex Yradex enabled auto-merge (squash) September 15, 2025 12:14
@codspeed-hq
Copy link

codspeed-hq bot commented Sep 15, 2025

CodSpeed Performance Report

Merging #1752 will degrade performances by 11.92%

Comparing Yradex:fix/mtf-reload3 (91ce14c) with main (1a720e0)

Summary

⚡ 1 improvement
❌ 3 regressions
✅ 52 untouched

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
002-hello-reactLynx-destroyBackground 620.2 µs 704.1 µs -11.92%
transform 1000 effects 30.4 ms 32.5 ms -6.45%
transform 1000 view elements 46.5 ms 40.2 ms +15.53%
basic-performance-div-10000 388.3 ms 409.6 ms -5.21%

@Yradex Yradex merged commit a36e512 into lynx-family:main Sep 15, 2025
51 of 52 checks passed
@Yradex Yradex deleted the fix/mtf-reload3 branch September 15, 2025 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants