Skip to content

Commit

Permalink
fix(App): Bugfix Fix memory leak in recipe polling loop
Browse files Browse the repository at this point in the history
  • Loading branch information
haraldox committed Feb 7, 2018
1 parent a585f2b commit c99848f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/models/Service.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default class Service {
id = '';
recipe = '';
webview = null;
timer = null;
events: {};

isAttached = false;
Expand Down
6 changes: 5 additions & 1 deletion src/stores/ServicesStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,12 +589,16 @@ export default class ServicesStore extends Store {
const delay = 1000;

if (service) {
if (service.timer !== null) {
clearTimeout(service.timer)
}

const loop = () => {
if (!service.webview) return;

service.webview.send('poll');

setTimeout(loop, delay);
service.timer = setTimeout(loop, delay);
};

loop();
Expand Down

0 comments on commit c99848f

Please sign in to comment.