test: strengthen worklet runtime guardrails#2373
Conversation
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughTests added across multiple packages to verify worklet compilation into distinct instances, worklet registration overwriting behavior, and bundler integration correctly including or excluding worklet-runtime based on usage patterns. Test logic migrated from scattered test case files to a centralized bundler guardrails test suite. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/react/worklet-runtime/src/workletRuntime.ts`:
- Around line 18-20: The initWorklet reset only clears the top-level
workletCache but doesn’t address nested child contexts that
transformWorkletInner in runWorklet rewrites by replacing nested _wkltId entries
with bound functions (leaving stale child worklets in reused ctxs via
_c/params). Fix by preserving or cloning the original nested worklet ctx
templates before any transformation and/or maintaining a registry mapping of
original ctx templates keyed by _wkltId so initWorklet can rebuild nested ctxs
from those templates; update initWorklet to iterate the registry and restore
nested ctxs (or clear transformed children) so entries referenced by _c and
params are re-resolved against the fresh registry rather than calling pre-init
bound functions (refer to initWorklet, workletCache, runWorklet,
transformWorkletInner, _wkltId, _c, params, and globalThis.lynxWorkletImpl).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 8c3e325e-cb45-405e-af36-58d46ff07cdf
📒 Files selected for processing (10)
packages/react/testing-library/src/__tests__/worklet.test.jsxpackages/react/transform/__test__/fixture.spec.jspackages/react/worklet-runtime/__test__/workletRuntime.test.jspackages/react/worklet-runtime/src/workletRuntime.tspackages/webpack/react-webpack-plugin/test/cases/worklet-runtime/chunk/a.jsxpackages/webpack/react-webpack-plugin/test/cases/worklet-runtime/chunk/index.jspackages/webpack/react-webpack-plugin/test/cases/worklet-runtime/chunk/test.config.cjspackages/webpack/react-webpack-plugin/test/cases/worklet-runtime/not-using/index.jspackages/webpack/react-webpack-plugin/test/cases/worklet-runtime/not-using/test.config.cjspackages/webpack/react-webpack-plugin/test/worklet-runtime.test.ts
Merging this PR will improve performance by ×4.3
Performance Changes
Comparing Footnotes
|
Web Explorer#8398 Bundle Size — 724.73KiB (0%).cdf5f12(current) vs 36b38eb main#8397(baseline) Bundle metrics
Bundle size by type
|
| Current #8398 |
Baseline #8397 |
|
|---|---|---|
382.38KiB |
382.38KiB |
|
340.36KiB |
340.36KiB |
|
1.99KiB |
1.99KiB |
Bundle analysis report Branch Yradex:wt/move-mts-runtime-2-202... Project dashboard
Generated by RelativeCI Documentation Report issue
Summary by CodeRabbit
Summary
worklet-runtimeemission, single runtime-body injection, and unique main-thread worklet registrationsTesting
CI=true pnpm vitest run __test__/fixture.spec.js -t workletCI=true pnpm vitest run --project webpack/react test/worklet-runtime.test.ts test/cases.test.ts -t worklet-runtimeCI=true pnpm vitest run __test__/workletRuntime.test.js __test__/runOnMainThread.test.js __test__/runOnBackground.test.jsCI=true pnpm vitest run src/__tests__/worklet.test.jsxChecklist