Fixes #38495 - Fix memory leak bug in TemplateInvocation file#978
Conversation
kmalyjur
commented
Jun 13, 2025
|
Code looks good, Do you remember what actions showed the leak? |
There was a problem hiding this comment.
Pull Request Overview
Fixes a memory leak in the TemplateInvocation component by replacing a shared intervalId with a useRef-based interval tracker and ensuring all polling intervals are properly cleared.
- Use
useRef(intervalRef) instead of a module-scopeintervalIdto store the interval handle. - Update error handler and effect cleanup to clear
intervalRef.current. - Ensure cleanup logic runs on unmount and when polling should stop.
Comments suppressed due to low confidence (1)
webpack/JobInvocationDetail/TemplateInvocation.js:87
- [nitpick] Consider adding unit or integration tests to verify that the polling interval is cleared when the component unmounts or when
finishedbecomes true, to guard against regressions.
}, [finished, autoRefresh, setAPIOptions]);
| clearInterval(intervalRef.current); | ||
| } | ||
| return () => { | ||
| clearInterval(intervalId); | ||
| if (intervalRef.current) { | ||
| clearInterval(intervalRef.current); |
There was a problem hiding this comment.
After calling clearInterval, assign intervalRef.current = null to reset the ref and avoid clearing the same interval repeatedly on future renders.
|
Probably not related to this pr, but when I tried to changing the dropdown filter and then back to all statuses the table is empty (only when autoreload is true) |
651da1d to
02cb084
Compare
@MariaAga, the error always appears once after calling /api/job_invocations/id/hosts.
I don't know how to reproduce it, but I agree that it's probably a separate issue. |
MariaAga
left a comment
There was a problem hiding this comment.
The issue I described can be solved in another pr yes.
I cant reproduce the issue without the pr, but again, code look good