TheNetsky / Microsoft-Rewards-Script

Automated Microsoft Rewards script, using TypeScript, Cheerio and Playwright.
133 stars 33 forks source link

Adding auto-restart #96

Open serzak51 opened 3 months ago

serzak51 commented 3 months ago

Recently there have been a lot of random crash (the sessions issues, sometimes connection issue, or other errors that doesn't seem consistant). But a lot of these errors can be fixed with bruteforce and restarting the script multiple times. But it gets kinda annoying when it crash 5 times before booting, and when it end-up crashing in the middle of a 15 account batch. An auto-restart would be really great to tackle temporary issues I tried using pm2, but it's not restarting. I'm not sure if it's because my command is wrong or if it's because the code was never made with pm2 in mind

TheNetsky commented 3 months ago

I do not have plans of adding this, however feel free to create a fork and submit a PR with this feature.

xunilalala commented 3 months ago

I have also observed this phenomenon and through testing, gradually discovered that there are two locations where this issue occurs frequently. The first is when accessing rewards.bing.com at the beginning of startup, and the second is when the search page fails to load, resulting in the inability to locate sb_form_q. I believe that instead of compensating for this issue through automatic restarts, it would be more effective to perform targeted page refresh operations on the problematic sections. This is because automatic restarts consume time for tasks such as checking login status and points, among others.

serzak51 commented 3 months ago

Yeah, i guess that would make more sense. Thing is, i am not really good at programming things. I can modify simple things, but that's it. My solution is with a .bat that execute npm run start 2000 times, so that when the first command stop, the second one execute. Haven't tested it yet, but i don't see why it wouldn't work. But yeah it's really a temporary solution, there isn't even a loop to truly make it infinite (for some reason each time i tried to make a loop it just didn't work.). For those who want to make it, make a .bat with npm run start, copy it, make a line break, paste it, another line break, paste it again. From time to time copy everything to make it faster. This solution isn't pretty, but at least it works. Just be sure that it's working after ~10 minutes, because then it probably means something is wrong.