jef / streetmerchant

πŸ€– The world's easiest, most powerful stock checker
https://jef.buzz/streetmerchant
MIT License
4.97k stars 1.3k forks source link

Greacefully handle Restarting Chrome? #1913

Closed notatallshaw closed 3 years ago

notatallshaw commented 3 years ago

Expected Behavior

Errors generated by Restart Chrome Feature should be carefully handled

Current Behavior

By setting the new Restart Chrome Flag the performance is significantly improved on my machine (both CPU and memory as Chromium processes aren't endlessly spawned and kept around), however the script eventually fails as it does not handle the errors caused by restarting Chrome.

Am able to consistently reproduce this error but I do understand though if this is not a priority.

Steps to Reproduce

  1. Set the New Restart Chrome Feature to restart quite quickly: https://github.com/jef/streetmerchant/pull/1880
  2. Get errors that Look like this:
    [12:41:21 PM] error :: βœ– [amazon] zotac 3070 gaming - Navigation failed because browser has disconnected!
    [12:41:21 PM] error :: βœ– [bestbuy] nvidia 3070 founders edition - Navigation failed because browser has disconnected!
    [12:41:21 PM] error :: βœ– [newegg] zotac 3070 twin edge oc - Navigation failed because browser has disconnected!
    [12:41:22 PM] error :: Protocol error (Target.attachToTarget): Target closed.
    [12:41:22 PM] error :: Protocol error (Target.attachToTarget): Target closed.
    [12:41:22 PM] error :: Protocol error (Target.attachToTarget): Target closed.
  3. Script eventually fails with this error:
    
    \streetmerchant\node_modules\puppeteer\lib\cjs\puppeteer\common\Connection.js:208
            this._callbacks.set(id, { resolve, reject, error: new Error(), method });
                                                              ^

Error: Protocol error (Network.setUserAgentOverride): Target closed. at \streetmerchant\node_modules\puppeteer\lib\cjs\puppeteer\common\Connection.js:208:63 at new Promise () at CDPSession.send (\stock\streetmerchant\node_modules\puppeteer\lib\cjs\puppeteer\common\Connection.js:207:16) at next (\streetmerchant\node_modules\puppeteer-extra-plugin-stealth\evasions\sourceurl\index.js:30:43) at CDPSession.send (\streetmerchant\node_modules\puppeteer-extra-plugin-stealth\evasions\sourceurl\index.js:46:18) at Plugin.onPageCreated (\streetmerchant\node_modules\puppeteer-extra-plugin-stealth\evasions\user-agent-override\index.js:180:18) at runMicrotasks () at processTicksAndRejections (node:internal/process/task_queues:94:5) at async Plugin._onTargetCreated (\streetmerchant\node_modules\puppeteer-extra-plugin\dist\index.cjs.js:494:17) npm ERR! code 1 npm ERR! path \streetmerchant npm ERR! command failed npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c npm run compile && node build/src/index.js

npm ERR! A complete log of this run can be found in: npm ERR! \npm-cache_logs\2021-02-08T17_44_22_546Z-debug.log


## Environment

- OS: Windows

<!-- Put your dotenv within backticks below. Be sure to remove any secrets/passwords. -->
```dotenv
ASCII_BANNER="true"
ASCII_COLOR="true"
AUTO_ADD_TO_CART="true"
BROWSER_TRUSTED=
DESKTOP_NOTIFICATIONS="true"
DISCORD_NOTIFY_GROUP=
DISCORD_NOTIFY_GROUP_3060TI=
DISCORD_NOTIFY_GROUP_3070=
DISCORD_NOTIFY_GROUP_3080=
DISCORD_NOTIFY_GROUP_3090=
DISCORD_NOTIFY_GROUP_CORSAIR_SF=
DISCORD_NOTIFY_GROUP_RX6800=
DISCORD_NOTIFY_GROUP_RX6800XT=
DISCORD_NOTIFY_GROUP_RX6900XT=
DISCORD_NOTIFY_GROUP_RYZEN5600=
DISCORD_NOTIFY_GROUP_RYZEN5800=
DISCORD_NOTIFY_GROUP_RYZEN5900=
DISCORD_NOTIFY_GROUP_RYZEN5950=
DISCORD_NOTIFY_GROUP_SONYPS5C=
DISCORD_NOTIFY_GROUP_SONYPS5DE=
DISCORD_NOTIFY_GROUP_XBOXSX=
DISCORD_NOTIFY_GROUP_XBOXSS=
DISCORD_NOTIFY_GROUP_TEST=
DISCORD_WEB_HOOK=
EMAIL_PASSWORD=
EMAIL_TO=
EMAIL_USERNAME=
HEADLESS=
IN_STOCK_WAIT_TIME="60"
LOG_LEVEL=
LOW_BANDWIDTH="false"
MAX_PRICE_SERIES_3060TI=
MAX_PRICE_SERIES_3070="651"
MAX_PRICE_SERIES_3080="901"
MAX_PRICE_SERIES_3090=
MAX_PRICE_SERIES_CORSAIR_SF=
MAX_PRICE_SERIES_RX6800=
MAX_PRICE_SERIES_RX6800XT=
MAX_PRICE_SERIES_RX6900XT=
MAX_PRICE_SERIES_RYZEN5600=
MAX_PRICE_SERIES_RYZEN5800=
MAX_PRICE_SERIES_RYZEN5900="600"
MAX_PRICE_SERIES_RYZEN5950=
MAX_PRICE_SERIES_SONYPS5C=
MAX_PRICE_SERIES_SONYPS5DE=
MAX_PRICE_SERIES_XBOXSS=
MAX_PRICE_SERIES_XBOXSX=
MAX_PRICE_SERIES_TEST=
MICROCENTER_LOCATION=
MQTT_BROKER_ADDRESS=
MQTT_BROKER_PORT=
MQTT_CLIENT_ID=
MQTT_PASSWORD=
MQTT_QOS=
MQTT_TOPIC=
MQTT_USERNAME=
OPEN_BROWSER=
PAGE_BACKOFF_MIN="1800000"
PAGE_BACKOFF_MAX="7200000"
PAGE_SLEEP_MIN="60000"
PAGE_SLEEP_MAX="120000"
PAGE_TIMEOUT="120000"
PAGERDUTY_INTEGRATION_KEY=
PAGERDUTY_SEVERITY=
PHILIPS_HUE_API_KEY=
PHILIPS_HUE_CLOUD_ACCESS_TOKEN=
PHILIPS_HUE_CLOUD_CLIENT_ID=
PHILIPS_HUE_CLOUD_CLIENT_SECRET=
PHILIPS_HUE_CLOUD_REFRESH_TOKEN=
PHILIPS_HUE_LAN_BRIDGE_IP=
PHILIPS_HUE_LIGHT_COLOR=
PHILIPS_HUE_LIGHT_IDS=
PHILIPS_HUE_LIGHT_PATTERN=
PHONE_CARRIER=
PHONE_NUMBER=
PLAY_SOUND=
PROXY_ADDRESS=
PROXY_PROTOCOL=
PROXY_PORT=
PUSHBULLET=
PUSHOVER_EXPIRE=
PUSHOVER_RETRY=
PUSHOVER_TOKEN=
PUSHOVER_USER=
PUSHOVER_PRIORITY=
SCREENSHOT="true"
SHOW_ONLY_BRANDS=
SHOW_ONLY_MODELS=
SHOW_ONLY_SERIES="3070,3080,ryzen5900"
SLACK_CHANNEL=
SLACK_TOKEN=
SMTP_ADDRESS=
SMTP_PORT=
STORES="amazon,bestbuy,officedepot,newegg,walmart,antonline"
RESTART_TIME=180000
TELEGRAM_ACCESS_TOKEN=
TELEGRAM_CHAT_ID=
TWILIO_ACCOUNT_SID=
TWILIO_AUTH_TOKEN=
TWILIO_FROM_NUMBER=
TWILIO_TO_NUMBER=
TWITCH_ACCESS_TOKEN=
TWITCH_CHANNEL=
TWITCH_CLIENT_ID=
TWITCH_CLIENT_SECRET=
TWITCH_REFRESH_TOKEN=
TWITTER_ACCESS_TOKEN_KEY=
TWITTER_ACCESS_TOKEN_SECRET=
TWITTER_CONSUMER_KEY=
TWITTER_CONSUMER_SECRET=
TWITTER_TWEET_TAGS=
WEB_PORT=

Logs

0 verbose cli [
0 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
0 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
0 verbose cli   'run',
0 verbose cli   'start'
0 verbose cli ]
1 info using npm@7.5.1
2 info using node@v15.8.0
3 timing config:load:defaults Completed in 4ms
4 timing config:load:file:C:\Program Files\nodejs\node_modules\npm\npmrc Completed in 5ms
5 timing config:load:builtin Completed in 5ms
6 timing config:load:cli Completed in 2ms
7 timing config:load:env Completed in 0ms
8 timing config:load:file:streetmerchant\.npmrc Completed in 1ms
9 timing config:load:project Completed in 2ms
10 timing config:load:file:\.npmrc Completed in 0ms
11 timing config:load:user Completed in 0ms
12 timing config:load:file:\npm\etc\npmrc Completed in 0ms
13 timing config:load:global Completed in 0ms
14 timing config:load:cafile Completed in 1ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:setUserAgent Completed in 1ms
17 timing config:load:setEnvs Completed in 1ms
18 timing config:load Completed in 16ms
19 verbose npm-session ff7440782fca7023
20 timing npm:load Completed in 29ms
21 timing command:run-script Completed in 2547379ms
22 verbose stack Error: command failed
22 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\promise-spawn\index.js:64:27)
22 verbose stack     at ChildProcess.emit (node:events:378:20)
22 verbose stack     at maybeClose (node:internal/child_process:1067:16)
22 verbose stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
23 verbose cwd \streetmerchant
24 verbose Windows_NT 10.0.19042
25 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "start"
26 verbose node v15.8.0
27 verbose npm  v7.5.1
28 error code 1
29 error path \streetmerchant
30 error command failed
31 error command C:\WINDOWS\system32\cmd.exe /d /s /c npm run compile && node build/src/index.js
32 verbose exit 1
github-actions[bot] commented 3 years ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

notatallshaw commented 3 years ago

I've since got a much more powerful computer, so I don't personally experience this issue any more, but it still would probably be good?

github-actions[bot] commented 3 years ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 10 days

github-actions[bot] commented 3 years ago

This issue has been closed because it is stale. Reopen if necessary.