Replit (hacker plan) ignores text document when it restarts (always-on)

I use a large number of scripts to act when some stuff happen on my subreddits.

Until last week, it used to work good, without any problem whatsoever, for example one of them is to congratulate users when they reach a certain amount of upvotes (by commenting an event we host). Here’s my code :

for submission in reddit.subreddit(sub).new(limit=None):
    idCheckerCom = open("idCheckerCom", "r")
    idCheckerMod = open("idCheckerMod", "r")
    if str(submission.id) not in idCheckerCom.read():
        if submission.score >= int(float(amount)):
            if str(submission.created_utc) > start:
                with open("idCheckerCom", "a") as f:
                    f.write(str(submission.id) + "\n")
                do_something()

However now when the repl restarts it will completely ignore ligne 4 (if str(submission.id) not in idCheckerCom.read():) (or it will not read the document properly, I don’t know) and it will message the user once again every time the script restarts. I should add that manual restarts do not reproduce this error, only when the repl goes to sleep and is back up with always on.

Last night it spammed various users 12 times. This is unacceptable.

What is causing this and how can I prevent it ?

Maybe it’s running into some kind of error trying to read the file, although I can’t think of a reason of the top of my head. For now I suggest making a bug report to replit, and then wrapping your file reads in a try except so if it is running into some kind of weird error it catches it.
You could also try having it check it actually did read the file.

Another thought that probably has nothing to do with this, but do you close the files when you are done with them? This could also be breaking stuff always on restarts the code.

1 Like

The file is read correctly because when the repl is manually restarted it works properly… And while it’s running it works as well, the issue comes from when the repl goes to sleep and is woken back with the always-on functionality.

How can I submit this bug ticket?

Yes I do close the file for every loop !

Thanks for your answer !

1 Like

i think the issue must be coming from the way replit restarts code when it’s always on, I wonder if it isn’t loading the file or something when your code is trying to read it. I’m going to mess with some always on repls and try and figure this out.
Follow the steps to get help > i found a bug here:

2 Likes

Thanks so much !! It’s very nice of you :heart: