Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client.logout() error #2110

Open
1 task done
ibrahim0132 opened this issue Mar 31, 2023 · 6 comments · May be fixed by #2661
Open
1 task done

client.logout() error #2110

ibrahim0132 opened this issue Mar 31, 2023 · 6 comments · May be fixed by #2661
Labels
bug Something isn't working

Comments

@ibrahim0132
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

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'
}

Expected behavior

na

Steps to Reproduce the Bug or Issue

na

Relevant Code

No response

Browser Type

Chromium

WhatsApp Account Type

WhatsApp Business

Does your WhatsApp account have multidevice enabled?

No, I am not using Multi Device

Environment

Node.js v18.12.0

Additional context

na

@ibrahim0132 ibrahim0132 added the bug Something isn't working label Mar 31, 2023
@LTY526
Copy link

LTY526 commented Apr 1, 2023

Try have your project & session folder on another folder? Not sure if Onedrive folder has some sort of special permission restrictions

@developer-choice124
Copy link

developer-choice124 commented Apr 4, 2023

image
I am also having the same issue,

location to session: D:\Ajay\Work\Electron JS\sessions
location to project: D:\Ajay\Work\Electron JS\evr\whatsapp_automation_frontend

I am making compressed build of whatsapp-web.js using @vercel/ncc.
I am using whatsapp-web.js as child process using nodeJs fork in the main process of my electron-react project.
Everything works fine except when I try to logout the user which was logged in by using the QR(LocalAuth strategy). logout ends with the error attached in the image.

OS & Environment
OS: Windows 10
Node: v18.12.1
Yarn: 1.22.19

@ibrahim0132
Copy link
Author

I have found the solution

  1. Go to the file: "node_modules/whatsapp-web.js/src/authStrategies/LocalAuth.js"

  2. Find the function end of the file:
    async logout() { if (this.userDataDir) { return (fs.rmSync ? fs.rmSync : fs.rmdirSync).call(this, this.userDataDir, { recursive: true }); } }

  3. Now Edit the function like this:

async logout() { if (this.userDataDir) { try{ return (fs.rmSync ? fs.rmSync : fs.rmdirSync).call(this, this.userDataDir, { recursive: true }); } catch{} } }

  1. Now the problem solved!
  2. Done!

@developer-choice124
Copy link

I have found the solution

  1. Go to the file: "node_modules/whatsapp-web.js/src/authStrategies/LocalAuth.js"
  2. Find the function end of the file:
    async logout() { if (this.userDataDir) { return (fs.rmSync ? fs.rmSync : fs.rmdirSync).call(this, this.userDataDir, { recursive: true }); } }
  3. Now Edit the function like this:

async logout() { if (this.userDataDir) { try{ return (fs.rmSync ? fs.rmSync : fs.rmdirSync).call(this, this.userDataDir, { recursive: true }); } catch{} } }

  1. Now the problem solved!
  2. Done!

This solution just avoid throwing error but issue still persists. Are we cleaning the session data good enough so that next try can generate QR properly? I am curious if it can do even this much

@qazgal1
Copy link

qazgal1 commented Jul 8, 2023

i am having the same problem please fix the logout function

@shirser121
Copy link
Collaborator

Please provide your code and WhatsApp Web version

@alechkos alechkos linked a pull request Dec 3, 2023 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants