⚡ Bolt: optimize PageTransition event listeners to prevent memory leaks#1137
Conversation
Refactored `PageTransition.astro` to use the Singleton Listener pattern for `astro:before-preparation`, `astro:after-preparation`, and `click` events. This prevents unbounded memory leaks and redundant main-thread work caused by script re-evaluations during Astro View Transitions.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
💡 What: Refactored
PageTransition.astroto use the Singleton Listener pattern forastro:before-preparation,astro:after-preparation, and documentclickevents.🎯 Why: Astro View Transitions can re-evaluate component scripts during navigation, causing anonymous event listeners to stack and execute redundantly, leading to memory leaks and performance degradation on the client side.
📊 Impact: Eliminates unbounded growth of global event listeners, preventing redundant main-thread executions and memory leaks on repeated page navigations.
🔬 Measurement: Verified locally using Playwright; the number of active event listeners on
documentandwindowno longer increases linearly with each page transition, maintaining a stable baseline memory footprint.PR created automatically by Jules for task 3919580246294493363 started by @kuasar-mknd