klept0/MS-Rewards-Farmer

[BUG] Code Crashing my pc

Contamiply opened this issue · 9 comments

Before submitting a bug report...

  • This bug wasn't already reported.
    (I have checked every bug report on GitHub)

Title

  • The title is no longer "[BUG] Title" and I edited it with the right error name.

Describe the bug

Note: I am newer to github and don't much about this subject, please go into extra detail to make me understand or smth. I started running this script with no issues a few days ago, so I decided to set it up with task scheduler. After figuring out how to do so I got it to work successfully. A day or two later I realized my pc was frozen when I got back to it in the morning(since it is scheduled to run at 2am). I ran the script myself through task scheduler and when it finished getting me points it just straight up crashed my pc, with a 90% chance I have to manually shut my pc off and a 10% chance of the pc fixing itself over a course of atleast one hour(sometimes it can take 5 hours). There are no errors in the log that hint a loop or something so I don't know whats wrong.

Here are the list of things I tried

  • Deleting then reinstalling the repo
  • Delete then reinstall some of the requirements
  • Find other people with the same problem
  • Deleting sessions folder

Here is some other info:

  • Windows 10 pro(I think its pro)
  • Running on cmd prompt - Uh thats it

Copy and paste your error

024-04-26 23:10:23,101 [WARNING] Error occurred: Message: javascript error: dashboard is not defined
(Session info: chrome=124.0.6367.78)
Stacktrace:
GetHandleVerifier [0x00C0C113+48259]
(No symbol) [0x00B9CA41]
(No symbol) [0x00A90A17]
(No symbol) [0x00A95B58]
(No symbol) [0x00A978CA]
(No symbol) [0x00B0A505]
(No symbol) [0x00AF0D9C]
(No symbol) [0x00B09B9C]
(No symbol) [0x00AF0B36]
(No symbol) [0x00AC570D]
(No symbol) [0x00AC62CD]
GetHandleVerifier [0x00EC6533+2908323]
GetHandleVerifier [0x00F03B4B+3159739]
GetHandleVerifier [0x00CA505B+674763]
GetHandleVerifier [0x00CAB21C+699788]
(No symbol) [0x00BA6244]
(No symbol) [0x00BA2298]
(No symbol) [0x00BA242C]
(No symbol) [0x00B94BB0]
BaseThreadInitThunk [0x75DDFCC9+25]
RtlGetAppContainerNamedObjectPath [0x77447C5E+286]
RtlGetAppContainerNamedObjectPath [0x77447C2E+238]
. Retrying... | hihamit937@iliken.com
2024-04-26 23:10:33,107 [INFO] hihamit937@iliken.com
2024-04-26 23:10:36,852 [INFO] patching driver executable C:\Users\Luke\appdata\roaming\undetected_chromedriver\undetected_chromedriver.exe
2024-04-26 23:10:41,634 [INFO] Screen size: 2278x1364
2024-04-26 23:10:41,649 [INFO] Device size: 2223x1213
2024-04-26 23:10:53,517 [INFO] [LOGIN] Logging-in...
2024-04-26 23:11:33,183 [INFO] [LOGIN] Logged-in !
2024-04-26 23:11:49,125 [INFO] [LOGIN] Ensuring you are logged into Bing...
2024-04-26 23:12:05,432 [INFO] [LOGIN] Logged-in successfully !
2024-04-26 23:12:05,454 [INFO] [POINTS] You have 2,082.00 points on your account
2024-04-26 23:12:05,458 [INFO] [DAILY SET] Trying to complete the Daily Set...
2024-04-26 23:13:31,182 [INFO] [DAILY SET] Completed the Daily Set successfully !
2024-04-26 23:13:31,182 [INFO] [PUNCH CARDS] Trying to complete the Punch Cards...
2024-04-26 23:13:31,874 [INFO] [PUNCH CARDS] Completed the Punch Cards successfully !
2024-04-26 23:13:54,087 [INFO] [MORE PROMOS] Trying to complete More Promotions...
2024-04-26 23:14:34,836 [INFO] [MORE PROMOS] Completed More Promotions successfully !
2024-04-26 23:14:35,817 [ERROR] [CRITICAL] ⚠️ Error occurred after 3 attempts. Closing script!⚠️ | hihamit937@iliken.com
2024-04-26 23:14:35,819 [INFO] [POINTS] Data saved for the next day.
(Pc Freezes Here)

Screenshots

There are no screenshots since I do not want to crash my pc again

Value of dashboard variable

Since github flagged me from creating a gist I cannot give you the source code.

Apparently when in the code closeBrowser is called, a dangling chrome process that uses 20% cpu is left open, this happens multiple times and eventually if ur pc is not capable enough i can see it even freezing, what i've done is modified the script after every closeBrowser call to execute a taskkill /F /IM "chrome.exe" /T command so it closes every chrome instance, might be a undetected chromedriver issue from what i've seen online

@Guido30 Since I dont know almost anything about python coding, I tried putting the command after each closeBrowser call in main.py and I recieved the error: [{ "resource": "/E:/MS-Rewards-Farmer-master/main.py", "owner": "_generated_diagnostic_collection_name_#2", "severity": 8, "message": "Statements must be separated by newlines or semicolons", "source": "Pylance", "startLineNumber": 257, "startColumn": 25, "endLineNumber": 257, "endColumn": 37 }] from VS code. Is there something I need to code to run this command? I realized it worked in cmd prompt so I am assuming so. Could you possibly give an example?

This is the line i've added
subprocess.run('taskkill /F /IM "chrome.exe" /T', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, creationflags=subprocess.DETACHED_PROCESS | subprocess.CREATE_NO_WINDOW)

also add an import subprocess at the beginning of the file

Thanks I searched up how to run commands on python and I put os.system('"taskkill /F /IM "chrome.exe" /T"') since
import os was already there. I also tested it earlier and it worked! Yay!

This is the line i've added subprocess.run('taskkill /F /IM "chrome.exe" /T', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, creationflags=subprocess.DETACHED_PROCESS | subprocess.CREATE_NO_WINDOW)

also add an import subprocess at the beginning of the file

Feel free to do a pull request and I will integrate it after testing

@klept0
Unfortunately this is not an issue related to the script itself, searching on google gave me a few results 1 2 and more, indicating its an undetected_chromedriver issue, also the workaround im using (killing all chrome processes after every closeBrowser) doesnt take into account people who might be using chrome while also running the script, its just a dirty way of doing it since im using firefox, other ways of band-aid fixing this issue until undetected_chromedriver fix it themself should be found but personally i have no motivation do so.

fair enough - I have tried to fix the errors from Undetected Chromedriver I see posted but sometimes one fix breaks multiple other things so I try to take the lesser of the evils in that aspect. I will pin this issue though so others can see it and decide if they would like to implement this fix on their end. Thank you for the input and feel free to give me a shout on TG if you have any ideas!

I found a way to fix this
in browser.py, change self.webdriver.quit() to self.webdriver.close()
Now the spawned chrome process finally gets closed properly rather than left open with 20% cpu usage

I found a way to fix this in browser.py, change self.webdriver.quit() to self.webdriver.close() Now the spawned chrome process finally gets closed properly rather than left open with 20% cpu usage

Made the change and pushed it - let me know if you see any issues with it