Skip to content

fix: prevent setInterval memory leak in setEffectParameters() - #5732

Merged
DedeHai merged 1 commit into
wled:mainfrom
yazdan-iot:fix/setinterval-memory-leak
Jul 12, 2026
Merged

fix: prevent setInterval memory leak in setEffectParameters()#5732
DedeHai merged 1 commit into
wled:mainfrom
yazdan-iot:fix/setinterval-memory-leak

Conversation

@yazdan-iot

@yazdan-iot yazdan-iot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

The setInterval() call was inside setEffectParameters() which runs frequently. Each call created a new interval without clearing the previous one, causing a memory leak.

Now the interval ID is stored in _selFxInterval and cleared before creating a new interval.

Summary by CodeRabbit

  • Bug Fixes
    • Improved effect selection updates by preventing overlapping timers.
    • Ensured the selected effect position refreshes reliably at regular intervals.

The setInterval() call was inside setEffectParameters() which runs
frequently. Each call created a new interval without clearing the
previous one, causing a memory leak.

Now the interval ID is stored in _selFxInterval and cleared before
creating a new interval.
@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2a6a63b0-b2f0-48a6-84df-11187da75ddc

📥 Commits

Reviewing files that changed from the base of the PR and between bc2c80d and d02c902.

📒 Files selected for processing (1)
  • wled00/data/index.js

Walkthrough

The effect-position updater now stores its interval ID, clears any existing interval, and starts a new 750ms interval on each update.

Changes

Effect-position timer management

Layer / File(s) Summary
Manage effect-position interval
wled00/data/index.js
Adds _selFxInterval and uses it to clear and replace the selected-effect-position update interval.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main fix: preventing a setInterval leak in setEffectParameters().
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

@softhack007 softhack007 added the javascript Pull requests that update Javascript code label Jul 11, 2026
@DedeHai
DedeHai merged commit e391183 into wled:main Jul 12, 2026
26 checks passed
DedeHai pushed a commit that referenced this pull request Jul 12, 2026
The setInterval() call was inside setEffectParameters() which runs
frequently. Each call created a new interval without clearing the
previous one, causing a memory leak.

Now the interval ID is stored in _selFxInterval and cleared before
creating a new interval.
aenertia pushed a commit to aenertia/WLED that referenced this pull request Aug 18, 2026
)

The setInterval() call was inside setEffectParameters() which runs
frequently. Each call created a new interval without clearing the
previous one, causing a memory leak.

Now the interval ID is stored in _selFxInterval and cleared before
creating a new interval.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug javascript Pull requests that update Javascript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants