c4a5c45 fix: clean up all event listeners in +layout.svelte onMount
📊 Changes
1 file changed (+15 additions, -7 deletions)
View changed files
📝src/routes/+layout.svelte (+15 -7)
📄 Description
Summary
Fix memory leaks in +layout.svelte by properly cleaning up all event listeners added in onMount.
Problem
The onMount hook adds event listeners for message, touchstart, touchmove, touchend, visibilitychange, and resize, but the cleanup function only removes the resize listener. The anonymous touch handlers cannot be removed because they have no reference. This causes memory leaks during navigation and hot-reloads.
Solution
Extract anonymous touch event handlers into named functions (touchstartHandler, touchmoveHandler, touchendHandler)
Add { passive: false } to touchmove listener to allow preventDefault()
Update the onMount cleanup function to remove all event listeners
Fixed
Memory leaks caused by unremoved event listeners during component unmount
Touch event handlers now properly cleaned up on navigation
Changed
Refactored anonymous touch handlers into named functions for proper cleanup
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
## 📋 Pull Request Information
**Original PR:** https://github.com/open-webui/open-webui/pull/20913
**Author:** [@sjhddh](https://github.com/sjhddh)
**Created:** 1/23/2026
**Status:** ✅ Merged
**Merged:** 1/29/2026
**Merged by:** [@tjbck](https://github.com/tjbck)
**Base:** `dev` ← **Head:** `fix/layout-memory-leak`
---
### 📝 Commits (1)
- [`c4a5c45`](https://github.com/open-webui/open-webui/commit/c4a5c4577defcb107514c59d3297dc8647786ae8) fix: clean up all event listeners in +layout.svelte onMount
### 📊 Changes
**1 file changed** (+15 additions, -7 deletions)
<details>
<summary>View changed files</summary>
📝 `src/routes/+layout.svelte` (+15 -7)
</details>
### 📄 Description
## Summary
Fix memory leaks in `+layout.svelte` by properly cleaning up all event listeners added in `onMount`.
## Problem
The `onMount` hook adds event listeners for `message`, `touchstart`, `touchmove`, `touchend`, `visibilitychange`, and `resize`, but the cleanup function only removes the `resize` listener. The anonymous touch handlers cannot be removed because they have no reference. This causes memory leaks during navigation and hot-reloads.
## Solution
1. Extract anonymous touch event handlers into named functions (`touchstartHandler`, `touchmoveHandler`, `touchendHandler`)
2. Add `{ passive: false }` to `touchmove` listener to allow `preventDefault()`
3. Update the `onMount` cleanup function to remove **all** event listeners
### Fixed
- Memory leaks caused by unremoved event listeners during component unmount
- Touch event handlers now properly cleaned up on navigation
### Changed
- Refactored anonymous touch handlers into named functions for proper cleanup
---
### Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms.
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/20913
Author: @sjhddh
Created: 1/23/2026
Status: ✅ Merged
Merged: 1/29/2026
Merged by: @tjbck
Base:
dev← Head:fix/layout-memory-leak📝 Commits (1)
c4a5c45fix: clean up all event listeners in +layout.svelte onMount📊 Changes
1 file changed (+15 additions, -7 deletions)
View changed files
📝
src/routes/+layout.svelte(+15 -7)📄 Description
Summary
Fix memory leaks in
+layout.svelteby properly cleaning up all event listeners added inonMount.Problem
The
onMounthook adds event listeners formessage,touchstart,touchmove,touchend,visibilitychange, andresize, but the cleanup function only removes theresizelistener. The anonymous touch handlers cannot be removed because they have no reference. This causes memory leaks during navigation and hot-reloads.Solution
touchstartHandler,touchmoveHandler,touchendHandler){ passive: false }totouchmovelistener to allowpreventDefault()onMountcleanup function to remove all event listenersFixed
Changed
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.