open-wa / wa-automate-deploy-heroku

Easy API deployment for Heroku
https://doc.openwa.dev
Other
14 stars 11 forks source link

`UPDATING @OPEN-WA` reboot loop #9

Closed Skowt closed 3 years ago

Skowt commented 3 years ago

I've deployed the API to Heroku and it appears that it's constantly trying to update and it saves changes to package-lock.json which is ephemeral because Heroku doesn't store files between reboots, so it results in a reboot loop.

Is there a way to either disable updates or prevent this loop from occurring?

Logs:

2021-03-08T16:28:00.262117+00:00 app[web.1]: - Authenticated
2021-03-08T16:28:00.262594+00:00 app[web.1]: - Injecting api
2021-03-08T16:28:03.148657+00:00 app[web.1]: - WAPI Injected
2021-03-08T16:28:03.228906+00:00 app[web.1]: - The session is invalid. Retrying
2021-03-08T16:28:03.387940+00:00 app[web.1]: UPDATING @OPEN-WA
2021-03-08T16:28:29.429384+00:00 app[web.1]: npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
2021-03-08T16:28:30.198248+00:00 app[web.1]: npm WARN deprecated har-validator@5.1.5: this library is no longer supported
2021-03-08T16:28:53.810166+00:00 app[web.1]: npm WARN rm not removing /app/node_modules/.bin/semver as it wasn't installed by /app/node_modules/semver
2021-03-08T16:28:53.878600+00:00 app[web.1]: npm WARN rm not removing /app/node_modules/.bin/tsc as it wasn't installed by /app/node_modules/typescript
2021-03-08T16:28:53.878932+00:00 app[web.1]: npm WARN rm not removing /app/node_modules/.bin/tsserver as it wasn't installed by /app/node_modules/typescript
2021-03-08T16:29:04.162755+00:00 app[web.1]: 
2021-03-08T16:29:04.162764+00:00 app[web.1]: > puppeteer@8.0.0 install /app/node_modules/puppeteer
2021-03-08T16:29:04.162765+00:00 app[web.1]: > node install.js
2021-03-08T16:29:04.162765+00:00 app[web.1]: 
2021-03-08T16:29:10.180648+00:00 app[web.1]: 
2021-03-08T16:29:19.643527+00:00 app[web.1]: Chromium (856583) downloaded to /app/node_modules/puppeteer/.local-chromium/linux-856583
2021-03-08T16:29:19.968884+00:00 app[web.1]: 
2021-03-08T16:29:19.968903+00:00 app[web.1]: > @open-wa/wa-automate@3.9.0 postinstall /app/node_modules/@open-wa/wa-automate
2021-03-08T16:29:19.968904+00:00 app[web.1]: > patch-package
2021-03-08T16:29:19.968904+00:00 app[web.1]: 
2021-03-08T16:29:20.260620+00:00 app[web.1]: patch-package 6.4.6
2021-03-08T16:29:20.261450+00:00 app[web.1]: Applying patches...
2021-03-08T16:29:20.265741+00:00 app[web.1]: Error: Patch file found for package swagger-stats which is not present at node_modules/swagger-stats
2021-03-08T16:29:20.265742+00:00 app[web.1]: 
2021-03-08T16:29:20.265743+00:00 app[web.1]:   If this package is a dev dependency, rename the patch file to
2021-03-08T16:29:20.265744+00:00 app[web.1]:   
2021-03-08T16:29:20.265744+00:00 app[web.1]:     swagger-stats+0.95.18.dev.patch
2021-03-08T16:29:20.265744+00:00 app[web.1]: 
2021-03-08T16:29:20.265864+00:00 app[web.1]: ---
2021-03-08T16:29:20.265957+00:00 app[web.1]: patch-package finished with 1 error(s).
2021-03-08T16:29:21.012305+00:00 app[web.1]: npm notice created a lockfile as package-lock.json. You should commit this file.
2021-03-08T16:29:21.027469+00:00 app[web.1]: npm WARN @open-wa/wa-automate@3.9.0 requires a peer of fluent-ffmpeg@^2.1.2 but none is installed. You must install peer dependencies yourself.
2021-03-08T16:29:21.040162+00:00 app[web.1]: npm WARN @open-wa/wa-automate@3.9.0 requires a peer of sharp@^0.27.0 but none is installed. You must install peer dependencies yourself.
2021-03-08T16:29:21.052879+00:00 app[web.1]: npm WARN open-wa-deploy-heroku@1.0.0 license should be a valid SPDX license expression
2021-03-08T16:29:21.053418+00:00 app[web.1]: 
2021-03-08T16:29:21.056693+00:00 app[web.1]: + @open-wa/wa-automate@3.9.0
2021-03-08T16:29:21.056694+00:00 app[web.1]: added 228 packages from 134 contributors, removed 139 packages, updated 483 packages and audited 711 packages in 77.037s
2021-03-08T16:29:21.652011+00:00 app[web.1]: 
2021-03-08T16:29:21.652027+00:00 app[web.1]: 59 packages are looking for funding
2021-03-08T16:29:21.652028+00:00 app[web.1]:   run `npm fund` for details
2021-03-08T16:29:21.652028+00:00 app[web.1]: 
2021-03-08T16:29:21.653521+00:00 app[web.1]: found 1 moderate severity vulnerability
2021-03-08T16:29:21.653523+00:00 app[web.1]:   run `npm audit fix` to fix them, or `npm audit` for details
2021-03-08T16:29:21.778446+00:00 app[web.1]: UPDATED SUCCESSFULLY
2021-03-08T16:29:21.781338+00:00 app[web.1]: RESTARTING PROCESS
2021-03-08T16:29:22.175146+00:00 heroku[web.1]: Process exited with status 0
2021-03-08T16:29:22.224070+00:00 heroku[web.1]: State changed from up to crashed
2021-03-08T16:29:22.236329+00:00 heroku[web.1]: State changed from crashed to starting
2021-03-08T16:29:51.317896+00:00 heroku[web.1]: Starting process with command `npm start`
2021-03-08T16:29:55.540637+00:00 app[web.1]: [heroku-exec] Starting
2021-03-08T16:29:56.314897+00:00 app[web.1]: 
2021-03-08T16:29:56.314927+00:00 app[web.1]: > open-wa-deploy-heroku@1.0.0 start /app
2021-03-08T16:29:56.314929+00:00 app[web.1]: > npx @open-wa/wa-automate --disable-spins --port $PORT --popup --in-docker --qr-timeout 0 -k $API_KEY --keep-alive --keep-updated --executable-path="/app/.apt/usr/bin/google-chrome"
2021-03-08T16:29:56.314929+00:00 app[web.1]: 
2021-03-08T16:29:59.677836+00:00 app[web.1]: fresh run
2021-03-08T16:30:00.031586+00:00 app[web.1]: ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
2021-03-08T16:30:00.031597+00:00 app[web.1]: ┃                                                                                                   ┃
2021-03-08T16:30:00.031598+00:00 app[web.1]: ┃   @open-wa/wa-automate                                                                            ┃
2021-03-08T16:30:00.031598+00:00 app[web.1]: ┃    💬 🤖 The most reliable NodeJS whatsapp library for chatbots with advanced features.           ┃
2021-03-08T16:30:00.031598+00:00 app[web.1]: ┃   Version: 3.1.10                                                                                 ┃
2021-03-08T16:30:00.031599+00:00 app[web.1]: ┃   Check out the latest changes: https://github.com/open-wa/wa-automate-nodejs#latest-changes      ┃
2021-03-08T16:30:00.031599+00:00 app[web.1]: ┃                                                                                                   ┃
2021-03-08T16:30:00.031600+00:00 app[web.1]: ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
2021-03-08T16:30:00.141644+00:00 app[web.1]: You can also authenticate the session at: NA
2021-03-08T16:30:00.146048+00:00 app[web.1]: - Initializing WA
2021-03-08T16:30:00.310863+00:00 heroku[web.1]: State changed from starting to up
2021-03-08T16:30:05.903580+00:00 app[web.1]: - Browser Launched
2021-03-08T16:30:05.999375+00:00 app[web.1]: ┌─────────────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
2021-03-08T16:30:05.999396+00:00 app[web.1]: │       (index)       │                                                                    Values                                                                    │
2021-03-08T16:30:05.999397+00:00 app[web.1]: ├─────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
2021-03-08T16:30:05.999397+00:00 app[web.1]: │     WA_VERSION      │                                                                  '2.2106.5'                                                                  │
2021-03-08T16:30:05.999398+00:00 app[web.1]: │       PAGE_UA       │ 'WhatsApp/2.2037.6 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36' │
2021-03-08T16:30:05.999398+00:00 app[web.1]: │ WA_AUTOMATE_VERSION │                                                                   '3.1.10'                                                                   │
2021-03-08T16:30:05.999399+00:00 app[web.1]: │   BROWSER_VERSION   │                                                        'HeadlessChrome/88.0.4324.96'                                                         │
2021-03-08T16:30:05.999399+00:00 app[web.1]: │         OS          │                                                                 'Linux 4.4'                                                                  │
2021-03-08T16:30:05.999399+00:00 app[web.1]: │      START_TS       │                                                                1615221005944                                                                 │
2021-03-08T16:30:05.999400+00:00 app[web.1]: └─────────────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
2021-03-08T16:30:06.019575+00:00 app[web.1]: - Authenticating
2021-03-08T16:30:17.491319+00:00 app[web.1]: - Authenticated
2021-03-08T16:30:17.491908+00:00 app[web.1]: - Injecting api
2021-03-08T16:30:36.869361+00:00 app[web.1]: - WAPI Injected
2021-03-08T16:30:37.081259+00:00 app[web.1]: - The session is invalid. Retrying
2021-03-08T16:30:37.538877+00:00 app[web.1]: UPDATING @OPEN-WA
smashah commented 3 years ago

@Skowt try setting this env to false:

https://github.com/open-wa/wa-automate-deploy-heroku/blob/6e4620570e178f9c07b1f561fc7a8665eeed8195/app.json#L37

If that solves the problem for you then I will go ahead and remove that as an option

Skowt commented 3 years ago

@smashah It's not trying to update but it does crash:

2021-03-08T17:50:19.288138+00:00 heroku[web.1]: State changed from up to crashed
2021-03-08T17:50:19.291915+00:00 heroku[web.1]: State changed from crashed to starting
2021-03-08T17:50:43.414599+00:00 heroku[web.1]: Starting process with command `npm start`
2021-03-08T17:50:46.962189+00:00 app[web.1]: [heroku-exec] Starting
2021-03-08T17:50:47.542404+00:00 app[web.1]: 
2021-03-08T17:50:47.542442+00:00 app[web.1]: > open-wa-deploy-heroku@1.0.0 start /app
2021-03-08T17:50:47.542446+00:00 app[web.1]: > npx @open-wa/wa-automate --disable-spins --port $PORT --popup --in-docker --qr-timeout 0 -k $API_KEY --keep-alive --keep-updated --executable-path="/app/.apt/usr/bin/google-chrome"
2021-03-08T17:50:47.542447+00:00 app[web.1]: 
2021-03-08T17:50:49.617321+00:00 app[web.1]: fresh run
2021-03-08T17:50:49.975386+00:00 app[web.1]: ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
2021-03-08T17:50:49.975445+00:00 app[web.1]: ┃                                                                                                   ┃
2021-03-08T17:50:49.975446+00:00 app[web.1]: ┃   @open-wa/wa-automate                                                                            ┃
2021-03-08T17:50:49.975446+00:00 app[web.1]: ┃    💬 🤖 The most reliable NodeJS whatsapp library for chatbots with advanced features.           ┃
2021-03-08T17:50:49.975447+00:00 app[web.1]: ┃   Version: 3.1.10                                                                                 ┃
2021-03-08T17:50:49.975447+00:00 app[web.1]: ┃   Check out the latest changes: https://github.com/open-wa/wa-automate-nodejs#latest-changes      ┃
2021-03-08T17:50:49.975448+00:00 app[web.1]: ┃                                                                                                   ┃
2021-03-08T17:50:49.975449+00:00 app[web.1]: ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
2021-03-08T17:50:50.074307+00:00 app[web.1]: You can also authenticate the session at: NA
2021-03-08T17:50:50.076507+00:00 app[web.1]: - Initializing WA
2021-03-08T17:50:50.509249+00:00 heroku[web.1]: State changed from starting to up
2021-03-08T17:50:52.578764+00:00 app[web.1]: - Browser Launched
2021-03-08T17:50:52.599040+00:00 app[web.1]: ┌─────────────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
2021-03-08T17:50:52.599052+00:00 app[web.1]: │       (index)       │                                                                    Values                                                                    │
2021-03-08T17:50:52.599053+00:00 app[web.1]: ├─────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
2021-03-08T17:50:52.599053+00:00 app[web.1]: │     WA_VERSION      │                                                                  '2.2106.5'                                                                  │
2021-03-08T17:50:52.599054+00:00 app[web.1]: │       PAGE_UA       │ 'WhatsApp/2.2037.6 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36' │
2021-03-08T17:50:52.599054+00:00 app[web.1]: │ WA_AUTOMATE_VERSION │                                                                   '3.1.10'                                                                   │
2021-03-08T17:50:52.599055+00:00 app[web.1]: │   BROWSER_VERSION   │                                                        'HeadlessChrome/88.0.4324.96'                                                         │
2021-03-08T17:50:52.599055+00:00 app[web.1]: │         OS          │                                                                 'Linux 4.4'                                                                  │
2021-03-08T17:50:52.599055+00:00 app[web.1]: │      START_TS       │                                                                1615225852586                                                                 │
2021-03-08T17:50:52.599056+00:00 app[web.1]: └─────────────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
2021-03-08T17:50:52.599339+00:00 app[web.1]: - Authenticating
2021-03-08T17:50:54.483197+00:00 app[web.1]: - Authenticate to continue
2021-03-08T17:50:56.522025+00:00 app[web.1]: Error: Evaluation failed: ReferenceError: getQrPng is not defined
2021-03-08T17:50:56.522075+00:00 app[web.1]:     at __puppeteer_evaluation_script__:1:1
2021-03-08T17:50:56.522086+00:00 app[web.1]:     at ExecutionContext._evaluateInternal (/app/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:171:23)
2021-03-08T17:50:56.522087+00:00 app[web.1]:     at processTicksAndRejections (internal/process/task_queues.js:97:5)
2021-03-08T17:50:56.522087+00:00 app[web.1]:     at async ExecutionContext.evaluate (/app/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:106:16)
2021-03-08T17:50:56.588875+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-03-08T17:50:56.589323+00:00 app[web.1]: npm ERR! errno 1
2021-03-08T17:50:56.599928+00:00 app[web.1]: npm ERR! open-wa-deploy-heroku@1.0.0 start: `npx @open-wa/wa-automate --disable-spins --port $PORT --popup --in-docker --qr-timeout 0 -k $API_KEY --keep-alive --keep-updated --executable-path="/app/.apt/usr/bin/google-chrome"`
2021-03-08T17:50:56.600039+00:00 app[web.1]: npm ERR! Exit status 1
2021-03-08T17:50:56.600157+00:00 app[web.1]: npm ERR! 
2021-03-08T17:50:56.600258+00:00 app[web.1]: npm ERR! Failed at the open-wa-deploy-heroku@1.0.0 start script.
2021-03-08T17:50:56.600478+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-03-08T17:50:56.610053+00:00 app[web.1]: 
2021-03-08T17:50:56.610248+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-03-08T17:50:56.610383+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2021-03-08T17_50_56_601Z-debug.log
2021-03-08T17:50:56.665055+00:00 heroku[web.1]: Process exited with status 1
2021-03-08T17:50:56.716771+00:00 heroku[web.1]: State changed from up to crashed

I'll reauthenticate to fix that. Thanks :)

smashah commented 3 years ago

Wow I am surprised in this new way that heroku has become a nuisance in my life. I will be switching deployment stuff to DO or some other less horrible service.

In order to fix this issue, you will need to redeploy using the Heroku button with the same environmental variables since dependabot PRs for open-wa will be automerged from now on.

Skowt commented 3 years ago

Ah yeah @smashah, it's a con of using the 'Deploy to Heroku' button: image

So my 'fix' in the meantime is to fork your repo, then I can set that as a deployment target in Heroku so whenever my repo updates, it will deploy. I then installed wei/Pull to automatically pull commits from your repo to my fork every few hours.

This should work for now. Happy to update the. README if it helps!

Skowt commented 3 years ago

Going to close this issue out since it's been resolved. Feel free to reopen but I don't think there are any actions left. Unless @smashah decides to update the default params to not 'AUTO_UPDATE'.

smashah commented 3 years ago

@Skowt done thanks. I will look into this and find a better way to interface with heroku (i think their marketplace apps update automatically)

Skowt commented 3 years ago

@smashah Sweet. Shout if you need some testing done