whatsapp-web.js icon indicating copy to clipboard operation
whatsapp-web.js copied to clipboard

Logout file delete operation not permitted Problem has been solved

Open ibrahim0132 opened this issue 1 year ago • 1 comments

When I am using the client.logout() then showing the below error

node:fs:1780 handleErrorFromBinding(ctx); ^

Error: EPERM: operation not permitted, unlink '?\C:\Users\ibrah\OneDrive\Desktop\Whatsapp_bot_example\server.wwebjs_auth\session\Default\Cache\Cache_Data\data_0' at unlinkSync (node:fs:1780:3) at _unlinkSync (node:internal/fs/rimraf:214:14) at fixWinEPERMSync (node:internal/fs/rimraf:306:5) at rimrafSync (node:internal/fs/rimraf:200:14) at node:internal/fs/rimraf:253:9 at Array.forEach () at _rmdirSync (node:internal/fs/rimraf:250:7) at fixWinEPERMSync (node:internal/fs/rimraf:304:5) at rimrafSync (node:internal/fs/rimraf:200:14) at node:internal/fs/rimraf:253:9 at Array.forEach () at _rmdirSync (node:internal/fs/rimraf:250:7) at fixWinEPERMSync (node:internal/fs/rimraf:304:5) at rimrafSync (node:internal/fs/rimraf:200:14) at node:internal/fs/rimraf:253:9 at Array.forEach () { errno: -4048, syscall: 'unlink', code: 'EPERM', path: '\?\C:\Users\ibrah\OneDrive\Desktop\Whatsapp_bot_example\server.wwebjs_auth\session\Default\Cache\Cache_Data\data_0' }

PR Details

Description

Related Issue

Motivation and Context

How Has This Been Tested

Types of changes

  • [ ] Dependency change
  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • [ ] My code follows the code style of this project.
  • [ ] I have updated the documentation accordingly (index.d.ts).

ibrahim0132 avatar Apr 04 '23 14:04 ibrahim0132

@ibrahim0132, I use this logic to wait for the pupBrowser to close before attempting the deletion. Maybe that could be better than a try/catch? It could be improved to add a max delay to prevent an infinite loop though

    // Wait for client.pupBrowser to be disconnected before deleting the folder
    while (client.pupBrowser.isConnected()) {
      await new Promise(resolve => setTimeout(resolve, 100))
    }

Let me know if you want me to handle the patch instead 🫡

chrishubert avatar Apr 30 '23 08:04 chrishubert

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar May 30 '23 10:05 stale[bot]

@ibrahim0132, I use this logic to wait for the pupBrowser to close before attempting the deletion. Maybe that could be better than a try/catch? It could be improved to add a max delay to prevent an infinite loop though

    // Wait for client.pupBrowser to be disconnected before deleting the folder
    while (client.pupBrowser.isConnected()) {
      await new Promise(resolve => setTimeout(resolve, 100))
    }

Let me know if you want me to handle the patch instead 🫡

This sounds like the fix to the issue. Thanks, and also thanks for @ibrahim0132 for reporting through this PR and bringing it to our light

purpshell avatar May 31 '23 10:05 purpshell