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 authentication doesn't work in packaged electron app #1855

Closed
1 task done
piedpie opened this issue Dec 1, 2022 · 5 comments
Closed
1 task done

Client authentication doesn't work in packaged electron app #1855

piedpie opened this issue Dec 1, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@piedpie
Copy link

piedpie commented Dec 1, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

UnhandledPromiseRejectionWarning: Error: Evaluation failed: ReferenceError: t is not defined at moduleRaid

Electron app when packaged doesn't seem to work.
Initially I was getting this error:

(node:4288) UnhandledPromiseRejectionWarning: Error: Could not find expected browser (chrome) locally. Run npm install to download the correct Chromium revision (982053). at y.launch (C:\Users\admin\AppData\Local\Programs\sample-whatsapp\resources\app.asar\dist\main\webpack:\node_modules\puppeteer\lib\cjs\puppeteer\node\Launcher.js:105:23) at launch (C:\Users\admin\AppData\Local\Programs\sample-whatsapp\resources\app.asar\dist\main\webpack:\node_modules\puppeteer\lib\cjs\puppeteer\node\Puppeteer.js:125:31) at e.exports.initialize (C:\Users\admin\AppData\Local\Programs\sample-whatsapp\resources\app.asar\dist\main\webpack:\node_modules\whatsapp-web.js\src\Client.js:100:39) at processTicksAndRejections (node:internal/process/task_queues:96:5)

Then I changed puppeteer options to set executable path to my google chrome exe like following:

const client = new Client({
    authStrategy: new LocalAuth({
      dataPath: './user',
    }),
    puppeteer: {
      executablePath:
        'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe',
    },
  });

Now we when we run the packaged application we get the qr code, qr event is being fired succcessfully.
But after scanning the qr code authenticated or ready events are never fired.
No other events like auth_failure or disconnected are either fired.

In this case when debugging the installed app I have seen the following error in logs:

(node:13604) UnhandledPromiseRejectionWarning: Error: Evaluation failed: ReferenceError: t is not defined at moduleRaid (eval at <anonymous> (:1:18), <anonymous>:1:29) at __puppeteer_evaluation_script__:1:68 at t.ExecutionContext._evaluateInternal (C:\Users\admin\AppData\Local\Programs\sample-whatsapp\resources\app.asar\dist\main\webpack:\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:221:19) at processTicksAndRejections (node:internal/process/task_queues:96:5) at t.ExecutionContext.evaluate (C:\Users\admin\AppData\Local\Programs\sample-whatsapp\resources\app.asar\dist\main\webpack:\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:110:9) at e.exports.initialize (C:\Users\admin\AppData\Local\Programs\sample-whatsapp\resources\app.asar\dist\main\webpack:\node_modules\whatsapp-web.js\src\Client.js:265:9) (node:13604) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)

This is happening on windows machine. I haven't tried on mac or linux.

I have created a sample repository on github, in case you want to see the code. Link is here.

It is a very simple app where we can scan the qr code and it prints the client events in the UI with the time.

Expected behavior

After scanning the qr code authenticated and ready events should be fired.
And we should be able to send and receive messages.

Steps to Reproduce the Bug or Issue

Clone the sample repo https://github.com/piedpie/sample-whatsapp

Package the app

npm run package

From release/build folder install the application.

Launch the installed app.

Additionally use debugtron to debug the installed app.

Relevant Code

No response

Browser Type

Google Chrome

WhatsApp Account Type

Standard

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

OS: Windows 10
Phone OS: Android
whatsapp-web.js version: 1.18.4
WhatsApp Web version : 2.2245.9
Node.js Version: v18.12.0

Additional context

I have tested with both normal and business accounts.

@piedpie piedpie added the bug Something isn't working label Dec 1, 2022
@jsuntura
Copy link

jsuntura commented Dec 2, 2022

Whatsapp authentication doesn't work

@piedpie piedpie changed the title Whatsapp authentication doesn't work in packaged electron app Client authentication doesn't work in packaged electron app Dec 3, 2022
@piedpie
Copy link
Author

piedpie commented Dec 24, 2022

Is there any update on this?
I am still facing the issue.

@dev-javid
Copy link

Whatsapp-web.js has native-dependencies, handle accordingly.
More details here

@Minenat69
Copy link

@piedpie did you figure it out ? I have the same issue

@piedpie
Copy link
Author

piedpie commented Jan 31, 2023

@Minenat69 as mentioned by @dev-javid WhatsApp web js seems to have some native module dependency so make sure you are taking care of same.
I am using ERB boilerplate so I installed WhatsApp web js in release folder as mentioned here in documentation
You can also check electron doc https://www.electronjs.org/docs/latest/tutorial/using-native-node-modules

@piedpie piedpie closed this as completed Feb 4, 2023
@alechkos alechkos mentioned this issue Feb 1, 2024
1 task
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

No branches or pull requests

3 participants