pedroslopez / whatsapp-web.js

A WhatsApp client library for NodeJS that connects through the WhatsApp Web browser app
https://wwebjs.dev
Apache License 2.0
15.21k stars 3.63k forks source link

TypeError: Cannot read properties of null (reading '1') #2885

Closed hussam-aldarwish closed 6 months ago

hussam-aldarwish commented 6 months ago

Is there an existing issue for this?

Describe the bug

I'm getting this TypeError when initializing the whatsapp client.

TypeError: Cannot read properties of null (reading '1')
    at LocalWebCache.persist (node_modules\whatsapp-web.js\src\webCache\LocalWebCache.js:34:69)
    at node_modules\whatsapp-web.js\src\Client.js:771:36
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

Expected behavior

It worked when I tried to skip local caching by directly return like the follwing

    async persist(indexHtml) {
         return;
       }

But whithout local cache file stored in /.wwebjs_cache As a temporary workaround

Steps to Reproduce the Bug or Issue

I already have another bot which was working properly, but whenever the client is restarted I faced this error.

Relevant Code

https://github.com/pedroslopez/whatsapp-web.js/blob/79f0563ae283b4ac3bf40c5e71aba28d78d16557/src/webCache/LocalWebCache.js#L34

Browser Type

Google Chrome

WhatsApp Account Type

WhatsApp Business

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

Additional context

No response

ichiopro commented 6 months ago

same with me. please help to fix it, thanks

RudyBJ commented 6 months ago

Estou com o mesmo problema, será que é devido a alguma atualização?

OmarAttia commented 6 months ago

same here

codebugged commented 6 months ago

@hussam-aldarwish Sir, can you please expedite this ? We are facing challenges at client's end

moradiyavipul commented 6 months ago

TypeError: Cannot read properties of null (reading '1') at LocalWebCache.persist (A:\whatsapp\node_modules\whatsapp-web.js\src\webCache\LocalWebCache.js:34:69) at A:\whatsapp\node_modules\whatsapp-web.js\src\Client.js:759:36 at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

jdic commented 6 months ago

2789

Just take the corresponding raw version from GitHub, here they are: https://github.com/wppconnect-team/wa-version/tree/main/html

when you already have it, (example: https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2402.5-beta.html), in the launch arguments you should put it like this:

const client: Client = new Client({
  webVersionCache: 
  {
    remotePath: 'URL PATH HERE',
    type: 'remote' 
  } 
})
gaurangDhameliya commented 6 months ago

2789

Just take the corresponding raw version from GitHub, here they are: https://github.com/wppconnect-team/wa-version/tree/main/html

when you already have it, (example: https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2402.5-beta.html), in the launch arguments you should put it like this:

const client: Client = new Client({
  webVersionCache: 
  {
    remotePath: 'URL PATH HERE',
    type: 'remote' 
  } 
})

Can you please tell me that which url i need to add in remotePath, And how can I get it?

jdic commented 6 months ago

In this link are the wweb version lists, choose the one that corresponds with your version of whatsapp-web.js, you can try with 2.2402.5-beta.html, click on that file inside the given github repository list and click where it says raw, now copy the actual URL of the page and paste it in remoteAuth, it should work.

image

something like this:

const client = new Client({
  webVersionCache: 
  {
    remotePath: 'https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2402.5-beta.html',
    type: 'remote' 
  } 
})

2789

Just take the corresponding raw version from GitHub, here they are: https://github.com/wppconnect-team/wa-version/tree/main/html when you already have it, (example: https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2402.5-beta.html), in the launch arguments you should put it like this:

const client: Client = new Client({
  webVersionCache: 
  {
    remotePath: 'URL PATH HERE',
    type: 'remote' 
  } 
})

Can you please tell me that which url i need to add in remotePath, And how can I get it?