norkator / poker-pocket-backend

Nitramite Poker Pocket light weight NodeJS poker game backend
https://pokerpocket.nitramite.com
MIT License
30 stars 20 forks source link

Out of range error #24

Closed Zagreus9723 closed 1 year ago

Zagreus9723 commented 1 year ago

-------- Results : Room 3 -------- --------ROUND RESULT----------- internal/buffer.js:82 throw new ERR_OUT_OF_RANGE(type || 'offset', ^ RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 8305. Received 7_480_365_372 at boundsError (internal/buffer.js:82:9) at Buffer.readUInt32LE (internal/buffer.js:216:5) at Object.evalCard (/home/ubuntu/poker-pocket-backend/src/app/evaluator.js:111:23) at Object.eval (/home/ubuntu/poker-pocket-backend/src/app/evaluator.js:95:16) at Object.evalHand (/home/ubuntu/poker-pocket-backend/src/app/evaluator.js:89:17) at Room.evaluatePlayerCards (/home/ubuntu/poker-pocket-backend/src/app/room.js:1194:26) at Room.roundResultsEnd (/home/ubuntu/poker-pocket-backend/src/app/room.js:467:28) at Room.staging (/home/ubuntu/poker-pocket-backend/src/app/room.js:301:12) at Timeout._onTimeout (/home/ubuntu/poker-pocket-backend/src/app/room.js:444:11) at listOnTimeout (internal/timers.js:554:17) { code: 'ERR_OUT_OF_RANGE' } [nodemon] app crashed - waiting for file changes before starting...


This happens after sending all cards to all players

norkator commented 1 year ago

I have not seen this issue but could you provide details of your config you used to set up rooms?

shrpne commented 1 year ago

I experienced this issue few times after building docker image in my production server. The issue was caused by HandRanks.dat having short length (around 400 in my case, in @Zagreus9723 it is 8305). I don't understand why this file can be such short length, logs of docker build was shown that the file was downloaded completely. Rebuilding docker image few times helps me fix this

shrpne commented 1 year ago

BTW i've implemented simple healthcheck, that makes app fail earlier in case of invalid HandRanks.dat file

const healthCheckRanksLength = require('./src/app/evaluator.js').ranks.length;
const healthCheckValidLength = 129951336;

if (healthCheckRanksLength !== healthCheckValidLength) {
 throw someError
}
Zagreus9723 commented 1 year ago

Thanks. I can test this now and see if redownloading works.

Zagreus9723 commented 1 year ago

How strange. Looks like that was the issue. I had to scp the file from my main machine to my server, server was truncating the file ~8k lines every time for some reason. Thanks!