Replit reconnects every 2 seconds

Question:
Replit connects and then instantly disconnects continuously. I am not on a work/school monitored device, and I have tried:

  • Forking the repl
  • Kill 1
  • Checking my internet
  • Checking Replit server status
  • Renaming the repl
  • Reloading, closing the tab, etc.
  • Different browsers

I’ve recorded this happening and uploaded it to Youtube. The link is in the repl itself because I’m not allowed to post too many links in a topic.

Repl link/Link to where the bug appears:
https://replit.com/@somethingML/advent-thing#main.cpp

Screenshots, links, or other helpful context:

code snippet
1 Like

It seems to me that one of your files is much too large.

When a repl completely runs out of memory, it kills itself and reconnects.
Since you are just booting up your repl, it isn’t being run so this must be something to do with the editor/files rather than your program.

And just from viewing your repl’s code, I can see that output.txt is so large that when the editor tries to load it up for viewing, it runs out of memory. (I couldn’t even view output.txt without the entire webpage crashing.)

So, try to avoid opening output.txt, delete it if you can. (Is it one of the editor’s tabs?) I was still able to view your other files from the cover page, so you could also copy your code to another repl.

2 Likes

They likely have output.txt open in one of their editor windows, which is causing a crash loop. @somethingML try to see if you have that tab open, and close it if you do.

2 Likes

Welcome back to ask, @somethingML!

Okay, it looks like your code is broken, and adds thousands of newlines to output.txt per second, quickly causing your repl to crash.

The problem is that that std::cin will output any text that hasn’t been already outputted, and will return an empty string if not. Now the empty text will have a newline added to it, thanks to this line:

cout << field.back() << "\n";

std::cout will now add the newline to output.txt, meaning that it will infinitely increase in size due to your while loop (which actually requires the text newline rather than \n in order to stop, and is called so many times it is impossible to type that in the time, although this is irrelevant). And as @NuclearPasta0 said,

The reason why you made this mistake is that usually when you want to print text, you would add a newline to the end of your output with std::cout, so it flushes it, and subsequent output would be placed on a new line. However, this is not the correct thing to do here.

Since you are constantly outputting due to an oversight, the fact you are outputting into a file, and the fact you are in an infinite loop, means that you are overcoming the storage limit.

:exploding_head:

1 Like