jespertheend / splix

MIT License
21 stars 6 forks source link

Tile points to a non existent player #122

Closed jespertheend closed 11 months ago

jespertheend commented 11 months ago

This is the only issue that really seems to crash the server right now. The last error from the log below keeps getting logged until the process is killed by the OOM killer for some reason. The error makes sense, it just tries to send the playing area to everyone who connects. But I'm not sure where the memory leak comes from.

Either way, we should either:

The first option is preferred, but the second option could be a good short term solution.

error: Uncaught (in worker "") (in promise) Error: Assertion failed, the tile points to a non existent player
catched in unhandledrejection Error: Unhandled error in child worker.
    at Worker.#pollControl (ext:runtime/11_workers.js:159:19)
    at eventLoopTick (ext:core/01_core.js:183:11)
Error: Unhandled error in child worker.
    at Worker.#pollControl (ext:runtime/11_workers.js:159:19)
    at eventLoopTick (ext:core/01_core.js:183:11)
Error: Assertion failed, the tile points to a non existent player
    at Game.getTileTypeForMessage (file:///home/runner/work/splix/splix/gameServer/src/gameplay/Game.js:248:10)
    at file:///home/runner/work/splix/splix/gameServer/src/gameplay/Game.js:218:16
    at file:///home/runner/work/splix/splix/gameServer/src/gameplay/Arena.js:155:21
    at compressTiles (file:///home/runner/work/splix/splix/gameServer/src/util/util.js:164:12)
    at Arena.getChunk (file:///home/runner/work/splix/splix/gameServer/src/gameplay/Arena.js:153:10)
    at Game.getArenaChunkForMessage (file:///home/runner/work/splix/splix/gameServer/src/gameplay/Game.js:217:22)
    at Player.sendChunk (file:///home/runner/work/splix/splix/gameServer/src/gameplay/Player.js:809:31)
    at Player.#sendRequiredEdgeChunks (file:///home/runner/work/splix/splix/gameServer/src/gameplay/Player.js:797:9)
    at Player.#currentPositionChanged (file:///home/runner/work/splix/splix/gameServer/src/gameplay/Player.js:716:31)
    at Player.loop (file:///home/runner/work/splix/splix/gameServer/src/gameplay/Player.js:613:34)
    at invokeEventListeners (ext:deno_web/02_event.js:797:5)
    at dispatch (ext:deno_web/02_event.js:654:9)
    at WebSocket.[[[eventLoop]]] (ext:deno_websocket/01_websocket.js:452:11)
    at eventLoopTick (ext:core/01_core.js:183:11)
jespertheend commented 11 months ago

Actually now that I think about it this is probably just main thread and arena worker not being synced

jespertheend commented 11 months ago

The weird thing is that the logs also say Uncaught (in worker ""), which seems to suggest that an error was thrown from inside the worker. Yet 'the tile points to a non existent' errors are only being thrown by the main thread.

jespertheend commented 11 months ago

Hmm I think I see what's going on. The main thread has a TypedMessage handler called notifyAreasFilled which is fired from within the worker. This in turn fires onRectFilled callbacks, causing getTileTypeForMessage to throw inside one of these callbacks. The TypedMessenger then catches the error and sends it to the worker, causing it to be thrown from inside the worker.

jespertheend commented 11 months ago

This seems fixed now