Main loop reset! Stage: waitForUsers



  • Since the recent updates I have been having serious issues with my private server. It runs for a little while (maybe a couple of thousand ticks), and then everything stops and the engine_main console keeps printing Main loop reset! Stage: waitforUsers.

    Restarting the server fixes it, but it's not too long before it happens again.

    I've seen this mentioned in relation to bots, but I have no bots running on this server - it's literally just one player.

    As an aside, is this the right place to put issues with the private server or should I put them in the Technical Issues and Bugs forum? Or open a github issue?

    Thanks.


  • Dev Team

    Are there any errors in the logs/engine_runner.log file?



  • engine_runner.log:

    isolated-vm timeout 3
    Source Keeper error Script execution timed out ungracefully, restarting virtual machine
    isolated-vm timeout 3
    isolated-vm timeout 3
    isolated-vm timeout 3
    Source Keeper error Script execution timed out ungracefully, restarting virtual machine
    Source Keeper error Script execution timed out ungracefully, restarting virtual machine
    Source Keeper error Script execution timed out ungracefully, restarting virtual machine
    isolated-vm timeout 3
    isolated-vm timeout 3
    isolated-vm timeout 3
    isolated-vm timeout 3
    Source Keeper error Script execution timed out ungracefully, restarting virtual machine
    Source Keeper error Script execution timed out ungracefully, restarting virtual machine
    Source Keeper error Script execution timed out ungracefully, restarting virtual machine
    Source Keeper error Script execution timed out ungracefully, restarting virtual machine
    isolated-vm timeout d829bbeb50ab6ca
    

    backend.log also contains several of these, though I don't think this is related as it seems to carry on anyway:

    Unhandled rejection: Error: Can't set headers after they are sent.
        at validateHeader (_http_outgoing.js:494:11)
        at ServerResponse.setHeader (_http_outgoing.js:501:3)
        at ServerResponse.header (C:\Program Files (x86)\Steam\steamapps\common\Screeps\server\package\node_modules\express\lib\response.js:719:10)
        at ServerResponse.send (C:\Program Files (x86)\Steam\steamapps\common\Screeps\server\package\node_modules\express\lib\response.js:164:12)
        at ServerResponse.json (C:\Program Files (x86)\Steam\steamapps\common\Screeps\server\package\node_modules\express\lib\response.js:250:15)
        at C:\Program Files (x86)\Steam\steamapps\common\Screeps\server\package\node_modules\q-json-response\q-json-response.js:17:14
        at _rejected (C:\Program Files (x86)\Steam\steamapps\common\Screeps\server\package\node_modules\q\q.js:844:24)
        at C:\Program Files (x86)\Steam\steamapps\common\Screeps\server\package\node_modules\q\q.js:870:30
        at Promise.when (C:\Program Files (x86)\Steam\steamapps\common\Screeps\server\package\node_modules\q\q.js:1122:31)
        at Promise.promise.promiseDispatch (C:\Program Files (x86)\Steam\steamapps\common\Screeps\server\package\node_modules\q\q.js:788:41)
    

    Thanks.


  • Dev Team

    What is the server version?



  • It's a steam server. The version file says v2.0.0.

    Additionally, this time I got the following error in engine_runner:

    Source Keeper error SyntaxError: Unexpected token u in JSON at position 0
        at JSON.parse (<anonymous>)
        at global._init.global._start (<isolated-vm>:16114:45)
        at (<isolated-vm boundary>)
        at make (C:\Program Files (x86)\Steam\steamapps\common\Screeps\server\package\node_modules\@screeps\driver\lib\runtime\make.js:180:34)
    

  • Dev Team

    The server version is displayed on the main launcher page when you start the server, version file is unrelated.

    Also, please find C:\Program Files (x86)\Steam\steamapps\common\Screeps\server\package\node_modules\isolated-vm\package.json and copy-paste its contents here.



  • Ah ok. Server version is 3.0.0.

    node_modules\isolated-vm\package.json:

    {
      "name": "isolated-vm",
      "version": "1.5.2",
      "description": "Access to multiple isolates",
      "main": "isolated-vm.js",
      "types": "isolated-vm.d.ts",
      "scripts": {
        "install": "node-gyp rebuild --release -j 4",
        "lint": "find src -name '*.cc' | xargs -n1 ./clang-tidy-wrapper",
        "test": "node test.js || nodejs test.js"
      },
      "repository": {
        "type": "git",
        "url": "git+https://github.com/laverdet/isolated-vm.git"
      },
      "author": "https://github.com/laverdet/",
      "license": "ISC",
      "gypfile": true,
      "bugs": {
        "url": "https://github.com/laverdet/isolated-vm/issues"
      },
      "homepage": "https://github.com/laverdet/isolated-vm#readme",
      "dependencies": {
        "electron": "^1.8.4",
        "electron-rebuild": "^1.7.3"
      }
    }
    


  • Have you guys found a solution yet? I am having the same problem on a raspberry Pi.

    I can connect to the Server but cant run any code in the console.

    Would be nice if we get this working



  • @skrat17 I got a Main Loop Reset, but without the other errors, although I get the same error in backend.log. I downgraded node to 8.11.3 and this problem went away.



  • I am still getting this issue with the steam version.



  • Has anyone fixed this yet? I still get it about every half hour and have to restart the server every time.



  • @unforeseen Could you tell how you downgraded node js to 8.11.3? And is this possible with steam client? Thanks



  • still get this error

    Main loop reset! Stage: waitForUsers
    Game time set to 6
    Main loop reset! Stage: waitForUsers
    Game time set to 7
    Main loop reset! Stage: waitForUsers
    Game time set to 8
    ...
    

    node.dll version is 8.9.3.0 cant find 8.11.3



  • I know this is an ancient thread, however I am running into this problem on a fresh install of Screeps on MacOS. After about 15-20 minutes, the local private server is useless and requires a manual force-quit/kill from the OS to terminate.

    The first indication that something is wrong is on the client after about 15 minutes, the client will start to stutter, and I see the message "Main loop reset! Stage: waitForUsers" in the server console - engine_main log. It's at this point that I notice an uptick in CPU usage, which started around 50%, system-wide. CPU will go up by about 10-15% on every time I see a reset error messge. The process responsible is called "Electron Helper." After about 10 minutes, and 4-5 more times of seeing the error message, the CPU is now burning at 100%, the client has completely stop moving (but is still rendering at 60-70fps), and every single tick results in a main loop reset error.

    At this point, my only option is to quit the server from the File->Quit menu, but that doesn't actually cause the CPU usage to go down. There is now an orphaned process called "Electron Helper" that must be forced killed. It appears to have been spawned by the server, but it doesn't exit when the server exits.

    Some potentially pertinent information about my particular macOS setup: I am running Catalina 10.15.2. I have many versions of Nodejs installed, and manage them with NVM as part of my daily work. My default linked version of Nodejs is v12.4.0. I am running a fresh install of Screeps server version v4.0.5 from Steam, and I have not modified it any way. I'm not sure if Screeps will use my system's version of Nodejs or a packaged version, if there is one.

    I may try setting my global node version to something different to see if that helps.



  • I fixed this by completely deleting all files from the screeps game directory and then validating the game. This effectively creates a fresh install.

    I had this on two computers..



  • @jerdaz Unfortunately this didn't do much, as this was fresh/clean install. I tired this on a completely different windows-based computer and observed the same stalling behavior, so it doesn't seem to be related to my particular macOS setup.