Creating Time Tracking Project with the help Electron JS + React Js

279 Views Asked by At

I are using three main things to track the time on user desktop machine

  1. SetTimeout and Interval (For updating the time and store the data of mintplus and screen Short in local database)
  2. Better-Queue (for sending the data to backend server)
  3. UiHooks to calculate the mouse and keystrokes

But issue is when we launch the build on different user s Macbook after sometime app goes on not responding (sometime I get app not responding in week or sometime in two week) but on window and linux it working fine

I check everything but I did t find any sequence through this I understand why app not responding come

Is there any suggestion and anyone face same issue ?

  1. I try to implement crash reports to find the issue but not get anything
  2. Change the setTimeout and interval with Node-Cron package but still issue there
1

There are 1 best solutions below

1
mad2man On

can you post your sample code in a codesandbox? Maybe you forgot to cleanup the setTimeout or setInterval if you are using it in an useEffect ?

useEffect(() => {
  const timer = window.setInterval(() => {
    // function of api call 
  }, 1000);

  return () => { 
    window.clearInterval(timer);
  }
}, [])