claabs / epicgames-freegames-node

Automatically login and find available free games the Epic Games Store. Sends you a prepopulated checkout link so you can complete the checkout after logging in. Supports multiple accounts, login sessions, and scheduled runs.
https://hub.docker.com/r/charlocharlie/epicgames-freegames
MIT License
1.35k stars 92 forks source link

Container fails with "new page did not work", spawns infinite chromium instances and kills the server #390

Closed bonnee closed 5 months ago

bonnee commented 5 months ago

After the image automatic overnight update, I woke up with an hung up server. I had several chromium processes that were consuming 100% CPU and filled both RAM and swap. I traced the leak back to this container and was able to reproduce the issue after a forced reset of the machine.

I believe the container is spawning infinite chromium processes because chromiumProcesses appears empty in the logs when the container tries to kill the failed chromium instance, and I see the PIDs number increasing in docker stats.

Screenshots or Logs

epicgames  | Run on startup: true
epicgames  | [2024-04-26 10:09:12.984 +0000] INFO: Started epicgames-freegames-node
epicgames  |     COMMIT_SHA: "e08fe11113382b3d07f04b8ff88d0d6c2fe601b8"
epicgames  |     BRANCH: "master"
epicgames  |     DISTRO: "alpine"
epicgames  | [2024-04-26 10:09:12.984 +0000] DEBUG: Performing version check
epicgames  |     PROJECT_NAME: "epicgames-freegames-node"
epicgames  |     BRANCH: "master"
epicgames  |     COMMIT_SHA: "e08fe11113382b3d07f04b8ff88d0d6c2fe601b8"
epicgames  | [2024-04-26 10:09:13.254 +0000] DEBUG: Starting web server
epicgames  | [2024-04-26 10:09:13.257 +0000] INFO: Checking free games for ---
epicgames  |     user: "---"
epicgames  | [2024-04-26 10:09:13.257 +0000] DEBUG: Launching a new browser
epicgames  |     user: "---"
epicgames  | [2024-04-26 10:09:17.493 +0000] DEBUG: Refresh auth token response
epicgames  |     user: "---"
epicgames  |     authResp: {
epicgames  |       "access_token": "---",
epicgames  |       "expires_in": 7200,
epicgames  |       "expires_at": "2024-04-26T12:09:17.550Z",
epicgames  |       "token_type": "bearer",
epicgames  |       "refresh_token": "---",
epicgames  |       "refresh_expires": 28800,
epicgames  |       "refresh_expires_at": "2024-04-26T18:09:17.550Z",
epicgames  |       "account_id": "---",
epicgames  |       "client_id": "---",
epicgames  |       "internal_client": true,
epicgames  |       "client_service": "prod-fn",
epicgames  |       "displayName": "---",
epicgames  |       "app": "prod-fn",
epicgames  |       "in_app_id": "---",
epicgames  |       "product_id": "prod-fn",
epicgames  |       "application_id": "---",
epicgames  |       "acr": "---",
epicgames  |       "auth_time": "2024-04-17T18:01:34.329Z"
epicgames  |     }
epicgames  | [2024-04-26 10:09:17.494 +0000] INFO: searchStrategy is `all`: searching for weekly and promotional games
epicgames  |     user: "---
epicgames  | [2024-04-26 10:09:17.494 +0000] DEBUG: Getting current weekly free games list
epicgames  |     user: "---"
epicgames  | [2024-04-26 10:09:17.495 +0000] DEBUG: Setting auth from device auth
epicgames  |     user: "---"
epicgames  |     deviceAuth: {
epicgames  |       "access_token": "---",
epicgames  |       "expires_in": 7200,
epicgames  |       "expires_at": "2024-04-26T12:09:17.550Z",
epicgames  |       "token_type": "bearer",
epicgames  |       "refresh_token": "---",
epicgames  |       "refresh_expires": 28800,
epicgames  |       "refresh_expires_at": "2024-04-26T18:09:17.550Z",
epicgames  |       "account_id": "---",
epicgames  |       "client_id": "---",
epicgames  |       "internal_client": true,
epicgames  |       "client_service": "prod-fn",
epicgames  |       "displayName": "---",
epicgames  |       "app": "prod-fn",
epicgames  |       "in_app_id": "---",
epicgames  |       "product_id": "prod-fn",
epicgames  |       "application_id": "---",
epicgames  |       "acr": "---",
epicgames  |       "auth_time": "2024-04-17T18:01:34.329Z"
epicgames  |     }
epicgames  | [2024-04-26 10:09:17.495 +0000] DEBUG: Logging in with puppeteer
epicgames  |     user: "---"
epicgames  | [2024-04-26 10:09:17.495 +0000] DEBUG: Launching a new browser
epicgames  |     user: "---"
epicgames  | [2024-04-26 10:09:21.675 +0000] DEBUG: Launching a new page
epicgames  |     user: "---"
epicgames  | [2024-04-26 10:09:36.689 +0000] DEBUG: Killing new browser processes spawned
epicgames  |     user: "---"
epicgames  |     chromiumProcesses: []
epicgames  | [2024-04-26 10:09:36.689 +0000] WARN: new page did not work after 15000ms. Trying again.
epicgames  |     user: "---"
epicgames  |     attempts: 0
epicgames  |     MAX_ATTEMPTS: 5
epicgames  | [2024-04-26 10:09:51.699 +0000] DEBUG: Killing new browser processes spawned
epicgames  |     user: "---"
epicgames  |     chromiumProcesses: []
epicgames  | [2024-04-26 10:09:51.699 +0000] WARN: new page did not work after 15000ms. Trying again.
epicgames  |     user: "---"
epicgames  |     attempts: 1
epicgames  |     MAX_ATTEMPTS: 5
epicgames  | [2024-04-26 10:10:06.710 +0000] DEBUG: Killing new browser processes spawned
epicgames  |     user: "---"
epicgames  |     chromiumProcesses: []
epicgames  | [2024-04-26 10:10:06.710 +0000] WARN: new page did not work after 15000ms. Trying again.
epicgames  |     user: "---"
epicgames  |     attempts: 2
epicgames  |     MAX_ATTEMPTS: 5
epicgames  | [2024-04-26 10:10:21.720 +0000] DEBUG: Killing new browser processes spawned
epicgames  |     user: "---"
epicgames  |     chromiumProcesses: []
epicgames  | [2024-04-26 10:10:21.720 +0000] WARN: new page did not work after 15000ms. Trying again.
epicgames  |     user: "---"
epicgames  |     attempts: 3
epicgames  |     MAX_ATTEMPTS: 5
epicgames  | [2024-04-26 10:10:36.729 +0000] DEBUG: Killing new browser processes spawned
epicgames  |     user: "---"
epicgames  |     chromiumProcesses: []
epicgames  | [2024-04-26 10:10:36.729 +0000] WARN: new page did not work after 15000ms. Trying again.
epicgames  |     user: "---"
epicgames  |     attempts: 4
epicgames  |     MAX_ATTEMPTS: 5
epicgames  | [2024-04-26 10:10:51.738 +0000] DEBUG: Killing new browser processes spawned
epicgames  |     user: "---"
epicgames  |     chromiumProcesses: []
epicgames  | [2024-04-26 10:10:51.738 +0000] ERROR: If not already, consider using the Debian (:bullseye-slim) version of the image. More: https://github.com/claabs/epicgames-freegames-node#docker-configuration
epicgames  |     user: "---"
epicgames  | [2024-04-26 10:10:51.738 +0000] WARN: Failed to lookup weekly free games
epicgames  |     user: "---"
epicgames  |     err: {
epicgames  |       "type": "Error",
epicgames  |       "message": "Could not do new page after 6 failed attempts.",
epicgames  |       "stack":
epicgames  |           Error: Could not do new page after 6 failed attempts.
epicgames  |               at retryFunction (/usr/app/src/common/puppeteer.ts:160:13)
epicgames  |               at safeNewPage (/usr/app/src/common/puppeteer.ts:175:16)
epicgames  |               at PuppetFreeGames.setupPage (/usr/app/src/puppet/base.ts:67:18)
epicgames  |               at PuppetFreeGames.request (/usr/app/src/puppet/free-games.ts:35:19)
epicgames  |               at PuppetFreeGames.getWeeklyFreeGames (/usr/app/src/puppet/free-games.ts:148:18)
epicgames  |               at PuppetFreeGames.getAllFreeGames (/usr/app/src/puppet/free-games.ts:404:27)
epicgames  |               at redeemAccount (/usr/app/src/index.ts:46:20)
epicgames  |               at async file:///usr/app/node_modules/p-queue/dist/index.js:187:36
epicgames  |     }
epicgames  | [2024-04-26 10:10:51.745 +0000] DEBUG: Getting global free games
epicgames  |     user: "---"
epicgames  | [2024-04-26 10:10:51.745 +0000] DEBUG: Setting auth from device auth
epicgames  |     user: "---"
epicgames  |     deviceAuth: {
epicgames  |       "access_token": "---",
epicgames  |       "expires_in": 7200,
epicgames  |       "expires_at": "2024-04-26T12:09:17.550Z",
epicgames  |       "token_type": "bearer",
epicgames  |       "refresh_token": "---",
epicgames  |       "refresh_expires": 28800,
epicgames  |       "refresh_expires_at": "2024-04-26T18:09:17.550Z",
epicgames  |       "account_id": "---",
epicgames  |       "client_id": "---",
epicgames  |       "internal_client": true,
epicgames  |       "client_service": "prod-fn",
epicgames  |       "displayName": "---",
epicgames  |       "app": "prod-fn",
epicgames  |       "in_app_id": "---",
epicgames  |       "product_id": "prod-fn",
epicgames  |       "application_id": "---",
epicgames  |       "acr": "---",
epicgames  |       "auth_time": "2024-04-17T18:01:34.329Z"
epicgames  |     }
epicgames  | [2024-04-26 10:10:51.745 +0000] DEBUG: Logging in with puppeteer
epicgames  |     user: "---"
epicgames  | [2024-04-26 10:10:51.745 +0000] DEBUG: Launching a new browser
epicgames  |     user: "---"
epicgames  | [2024-04-26 10:10:54.785 +0000] DEBUG: Launching a new page
epicgames  |     user: "---"

epicgames  | [2024-04-26 10:11:09.796 +0000] DEBUG: Killing new browser processes spawned
epicgames  |     user: "---"
epicgames  |     chromiumProcesses: []
epicgames  | [2024-04-26 10:11:09.796 +0000] WARN: new page did not work after 15000ms. Trying again.
epicgames  |     user: "---"
epicgames  |     attempts: 0
epicgames  |     MAX_ATTEMPTS: 5
claabs commented 5 months ago

Yeah, somethings up with chromium 124 in docker. As a hotfix, I rolled back to the previous image version, since the Alpine APK doesn't store its old versions of packages

konradmb commented 5 months ago

ARM images are shipping x86-64 binaries now, so they won't start. If someone needs a quick fix, pull docker.io/charlocharlie/epicgames-freegames:54c98a7c5e5d6b04d2be9f336a319be1b24c876d

claabs commented 5 months ago

Sorry about the chaos. Unfortunately I'm AFK for the next few days, so where it's at now is where it's gonna be for a bit.

konradmb commented 5 months ago

No problem, thank you for your continuous development of this app and sharing it with us for free.

claabs commented 5 months ago

Found this comment and removed --single-process, which seemed to fix it. I had used it as it was recommended to prevent zombie processes. Guess it was deprecated or something...