Closed rithienatan closed 1 month ago
Facing the same issue when retrieving the session data
Problem solved putting the code
async unCompressSession(compressedSessionPath) { await new Promise((resolve, reject) => { const zip = new AdmZip(compressedSessionPath); zip.extractAllToAsync(this.userDataDir, true, false, (err) => { if (err) { reject(err); } else { resolve(); } }); }); await promises.unlink(compressedSessionPath); }
I was able to resolved it by
1- installing the npm i adm-zip
2 - adding this in RemoteAuth.js
var AdmZip = require('adm-zip');
3- then replace the unCompressSession function with this
async unCompressSession(compressedSessionPath) {
await new Promise((resolve, reject) => {
const zip = new AdmZip(compressedSessionPath);
zip.extractAllToAsync(this.userDataDir, true, false, (err) => {
if (err) {
reject(err);
} else {
resolve();
}
});
});
await fs.promises.unlink(compressedSessionPath);
}
Hello guys, here is an update on this bug.
Once I fix this issue, I will close this report.
Hello everyone, this is the last update that I bring here:
Yesterday, I made a PR for this issue, but it already has an existing PR (#2412) related to this. So, I will wait for this PR to be approved and then close this issue report.
Awesome!
I fixed it in an official/recommended way on this commit: https://github.com/pedroslopez/whatsapp-web.js/pull/3200 Encourage maintainers to approve the PR.
While the PR is not approved, you can use my fork like this:
npm install github:bymarcelo/whatsapp-web.js#fix-remote-auth-unzip
NOTE: Recommended to use node version >= 18, tested v20
Is there an existing issue for this?
Describe the bug
After authenticated and throwing the "remote_session_saved" event. However, when we try to recover the session, it fails and whatsapp immediately redirect to the QR code page.
Expected behavior
RemoteAuth should restore the existing session correctly.
Steps to Reproduce the Bug or Issue
Relevant Code
RemoteAuth.js file:
Browser Type
Google Chrome
WhatsApp Account Type
Standard
Does your WhatsApp account have multidevice enabled?
Yes, I am using Multi Device
Environment
Additional context
I've seen this implementation - https://github.com/nkbhasker/nest-whatsapp citing by @abhikhedekar4241 on #2452 and I try too look what is different to this reffer application continue to work and I discover that
fs.createReadStream
does not uncompressing zip file properly.So, what i discover is replacing
fs.createReadStream
to AdmZip library, RemoteAuth start to working well again. - Probably this could be used to fix this issue.What I haven't discover is how solve this problem only using
fs.createReadStream
to uncompress zip file properly.Heres the code I encountered in https://github.com/nkbhasker/nest-whatsapp to temporarely fix this issue: