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

The example code is not reproducible #3044

Closed
1 task done
yhojann-cl opened this issue May 19, 2024 · 2 comments
Closed
1 task done

The example code is not reproducible #3044

yhojann-cl opened this issue May 19, 2024 · 2 comments

Comments

@yhojann-cl
Copy link

yhojann-cl commented May 19, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

The example code is not reproducible. In the repository readme.md it only indicates the installation of node, install the dependency and run the example script and that's it, but in reality there are many previous steps and even then it is not possible to completely reproduce:

  1. The component requires a specific version of nodejs, it would be a good idea to add instructions to set it as required in the package.json using engines option.
  2. Pupeeter browser installation: The library require the web browser of pupeeter, i install using npx @puppeteer/browsers install chrome@stable;.
  3. By default, puppeteer gives problems with the google chrome sandbox and you have to add special instructions to whatsapp web or it won't start: No usable sandbox on non root user Running as root without --no-sandbox is not supported. #344 This required instruction is not found in the readme file and that means that the example code cannot be reproduced in any way. I even recommend that disabling the sandbox be enabled by default.
  4. When running the example code with the pupeeter web browser and non-sandboxing configurations, a new LocalWebCache error appears: TypeError: Cannot read properties of null (reading '1') at LocalWebCache.js for fresh installation #3000 The solution is upgrade the library but i use the last version from npmjs. I solve the error setting a static version removing the regexp and adding const version = '2.2206.9';.
  5. The code says an other error after qr resolve throw new Error('Evaluation failed: ' + helper_js_1.helper.getExceptionMessage(exceptionDetails));. At this point I give up trying to get the script to work.

Expected behavior

Give indications of additional installations and configurations for minimum reproducibility and that the example script works without errors.

Steps to Reproduce the Bug or Issue

  1. Create the example script.
  2. Try run it.

Relevant Code

package.json:

{
  "name": "example",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "node index.js"
  },
  "engines": {
    "node": ">=18.0.0"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "whatsapp-web.js": "^1.23.0"
  }
}

index.js:

const { Client } = require('whatsapp-web.js');

const client = new Client({
  puppeteer: {
    headless: true,
    args: [
      '--no-sandbox',
      '--disable-setuid-sandbox',
      '--disable-dev-shm-usage',
      '--disable-accelerated-2d-canvas',
      '--no-first-run',
      '--no-zygote',
      '--disable-gpu'
    ]},
});

client.on('qr', (qr) => {
    // Generate and scan this code with your phone
    console.log('QR RECEIVED', qr);
});

client.on('ready', () => {
    console.log('Client is ready!');
});

client.on('message', msg => {
    if (msg.body == '!ping') {
        msg.reply('pong');
    }
});

client.initialize();

Browser Type

Google Chrome

WhatsApp Account Type

Standard

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

  • OS: Ubuntu 24.04 LTS.
  • Phone OS: Android.
  • whatsapp-web.js version 1.23.0
  • WhatsApp Web version: Can not find the version before the error message.
  • Node.js Version: v18.19.1

Additional context

No response

@yhojann-cl yhojann-cl added the bug Something isn't working label May 19, 2024
@edu-amr
Copy link

edu-amr commented May 19, 2024

I'm having the same problem, it seems like it stopped working out of nowhere, I remember everything was ok the last time I tested it, I think it was 5 days ago, in this case I went to test it this afternoon and it hasn't happened anymore.

@alechkos
Copy link
Collaborator

You have all the necessary information in the guide.

#1621

@alechkos alechkos removed the bug Something isn't working label May 19, 2024
Repository owner locked and limited conversation to collaborators May 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants