perf: extract tt delayed-event replay bundle optimizations#2340
perf: extract tt delayed-event replay bundle optimizations#2340colinaaa wants to merge 8 commits intolynx-family:mainfrom
Conversation
… event flush paths ( and ). This removes closure overhead and trims emitted code while preserving behavior. Runtime tests pass.\n\nResult: {"status":"keep","bundle_size":95402}
… and removing the standalone wrapper function. Preserves behavior and cuts bundle to 95,396 bytes. Runtime tests pass.\n\nResult: {"status":"keep","bundle_size":95396}
…move standalone wrapper function. Bundle improved to 95,385 bytes with tests passing.\n\nResult: {"status":"keep","bundle_size":95385}
… expression-bodied arrows in and post-hydration reassignment. Bundle reduced to 95,381 bytes with tests passing.\n\nResult: {"status":"keep","bundle_size":95381}
…le) and simplify delayed lifecycle flush by removing redundant truthy check on always-initialized array. Bundle improved to 95,375 bytes; tests pass.\n\nResult: {"status":"keep","bundle_size":95375}
…ch around calls. already handles handler exceptions, so behavior remains covered while trimming code. Bundle improved to 95,320 bytes and tests pass.\n\nResult: {"status":"keep","bundle_size":95320}
…on reassignment. This preserves pre-hydration buffering and post-hydration direct dispatch while deleting redundant code. Tests pass; bundle reduced to 95,193 bytes.\n\nResult: {"status":"keep","bundle_size":95193}
|
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 (2)
📝 WalkthroughWalkthroughRefactors event publishing in Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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)
📝 Coding Plan
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 Tip You can customize the tone of the review comments and chat replies.Configure the |
|
❌ 9 Tests Failed:
View the top 3 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4873050292
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
| }); | ||
| delayedEvents.length = 0; | ||
| for (const [handlerName, data] of delayedEvents) { |
There was a problem hiding this comment.
Guard delayed event replay against empty queue
When firstScreen runs without any pre-hydration events, delayedEvents is still undefined (it is lazily initialized in delayEvents.ts), so iterating it here throws a TypeError. That exception is caught by onLifecycleEvent, which stops the rest of firstScreen processing before patch commit and leaves hydration incomplete. This makes startup fail in flows where no delayed events were queued.
Useful? React with 👍 / 👎.
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/runtime/src/lynx/tt.ts`:
- Around line 132-138: The loop assumes delayedEvents is always defined and can
crash hydration; before iterating or setting delayedEvents.length, guard that
delayedEvents is truthy (e.g., not undefined/null) and is an array. Update the
logic around delayedEvents in the replay code that uses jsReadyEventIdSwap and
publishEvent so the for-loop and the subsequent delayedEvents.length = 0 only
run when delayedEvents exists, leaving behavior unchanged when it’s
uninitialized.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f355689b-ffe5-40e2-b0f7-32b6aeb2f6d9
📒 Files selected for processing (1)
packages/react/runtime/src/lynx/tt.ts
Merging this PR will improve performance by 7.15%
Performance Changes
Comparing Footnotes
|
Web Explorer#8225 Bundle Size — 385.21KiB (0%).964e9a3(current) vs 799fda8 main#8222(baseline) Bundle metrics
|
| Current #8225 |
Baseline #8222 |
|
|---|---|---|
155.59KiB |
155.59KiB |
|
35.1KiB |
35.1KiB |
|
0% |
0% |
|
8 |
8 |
|
8 |
8 |
|
238 |
238 |
|
16 |
16 |
|
2.97% |
2.97% |
|
4 |
4 |
|
0 |
0 |
Bundle size by type no changes
| Current #8225 |
Baseline #8222 |
|
|---|---|---|
254.26KiB |
254.26KiB |
|
95.85KiB |
95.85KiB |
|
35.1KiB |
35.1KiB |
Bundle analysis report Branch colinaaa:colin/0316/tt-replay-op... Project dashboard
Generated by RelativeCI Documentation Report issue
Why
What
Impact
Summary by CodeRabbit