open-wa / wa-automate-nodejs

💬 🤖 The most reliable tool for chatbots with advanced features. Be sure to 🌟 this repository for updates!
https://docs.openwa.dev/
Other
3.11k stars 588 forks source link

Session file affects disk space. #2566

Closed MarcosDLR closed 2 years ago

MarcosDLR commented 2 years ago

Hello.

I know this is not a bug, I would just like information regarding the following:

When I connect the phone number a folder with the name of the session is created, this folder grows as time goes by and disk space is affected. Is there any way to prevent this ?

smashah commented 2 years ago

I don't mind making some sort of script that trims the fat from the folder however, people will need to collate the list of resources that are safe to delete.

Most of the space is taken by the Default folder which itself is mostly Cache.

CleanShot 2022-03-15 at 14 09 12

CleanShot 2022-03-15 at 14 10 50

The cache includes things like the loading animation and the js/css/html resources for WA WEB which are served via the service worker. The service worker is bypassed anyways so the cache can theoretically be cleared.

smashah commented 2 years ago

This line forces the cache to stay enabled (default).

https://github.com/open-wa/wa-automate-nodejs/blob/ae6c5df7f85a2f2d1728e1e699539bb6fbf1a41b/src/controllers/browser.ts#L79

Will test by removing this

MarcosDLR commented 2 years ago

Thank you very much.

smashah commented 2 years ago

@MarcosDLR MD sessions reauthenticate just fine without forcing the cache to be enabled.

I will remove the if statement in the above mentioned line. This should disable the cache. Not sure if this will prevent the storage increase over time but lets try.

smashah commented 2 years ago

@github-actions run

âš¡ Release! âš¡ ```js (async () => { function exec(cmd) { console.log(execSync(cmd).toString()); } //set the version type process.env.VERS = "patch" // Config const gitUserEmail = "github-actions[bot]@users.noreply.github.com"; const gitUserName = "github-actions[bot]"; exec(`echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc`); exec(`git config --global user.email "${gitUserEmail}"`); exec(`git config --global user.name "${gitUserName}"`); exec(`npm i -D`); exec(`npm run release-ci $VERS`); // types only package exec('npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN') exec(`cd ./types-only && npm version $VERS && npm run build && npm publish && cd ..`); exec(`git commit -a -m 'updated types-only package'`); exec(`git push --force`); //comment on the issue var result = execSync(`npx auto-changelog -o ./tempchangelog.txt --commit-limit false --template ./compact-keepachangelog.hbs --stdout`).toString(); await postComment(result); //create changelog image exec(`npm run release-image`); exec(`git commit -a -m 'updated release-image'`); exec(`git push --force`); })(); ```
smashah commented 2 years ago

Changelog

🚀 Release 4.32.8 (2022-03-15)

MarcosDLR commented 2 years ago

Hello again, sorry for the inconvenience.

With the latest update the cache is resolved but the \Default\IndexedDB\https_web.whatsapp.com_0.indexeddb.leveldb folder grows exponentially. This creates .ldb and .log files.

smashah commented 2 years ago

@MarcosDLR can you delete the folder, re scan and track the growth over time with exact numbers please.

MarcosDLR commented 2 years ago

After 10 minutes the file grew 1,449 kb, this was with 90 messages received, but the file grows even without sending or receiving messages. The file grows depending on the type of message.

After several days this becomes a considerable consumption of space depending on the flow of messages.

image