whatsapp-web.js icon indicating copy to clipboard operation
whatsapp-web.js copied to clipboard

Error: Protocol error (Runtime.callFunctionOn): Target closed

Open rushan21pink opened this issue 2 years ago • 17 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Describe the bug

after restarting the client, I expect ->initialized ->ready, but I get an error. this happens quite often, the client is working properly and after some kind of global restart of the code (I use pm2 restart) it can stop at initialized

I tried adding '--shm-size=3gb' to the puppeteer arguments, but it didn't help and I had to delete the session folder and scan again

example of my client initialization image

Expected behavior

I expect successful initialization, I get nothing, then if I restart one channel individually, I get the same error

Error: Protocol error (Runtime.callFunctionOn): Target closed

Steps to Reproduce the Bug or Issue

I cannot repeat it, I do not know the reason for its appearance

Relevant Code

No response

Browser Type

Other (please write in Additional Context)

WhatsApp Account Type

Standard

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

"puppeteer": "^10.4.0", npm - 7.5.1, node - v15.8.0, "whatsapp-web.js": "^1.16.5"

Additional context

I do not know the browser version, I am connecting to puppeteer

sorry for the small amount of information and my English, I'm new to all this

rushan21pink avatar Apr 05 '22 12:04 rushan21pink

I'm having the same problem when I call the client.destroy() function.

DionlenoPiata avatar Apr 06 '22 19:04 DionlenoPiata

I'm having the same problem when I call the client.destroy() function.

Me too

gutopdznn avatar Apr 06 '22 23:04 gutopdznn

Is there an existing issue for this?

  • [x] I have searched the existing issues

Describe the bug

after restarting the client, I expect ->initialized ->ready, but I get an error. this happens quite often, the client is working properly and after some kind of global restart of the code (I use pm2 restart) it can stop at initialized

I tried adding '--shm-size=3gb' to the puppeteer arguments, but it didn't help and I had to delete the session folder and scan again

example of my client initialization image

Expected behavior

I expect successful initialization, I get nothing, then if I restart one channel individually, I get the same error

Error: Protocol error (Runtime.callFunctionOn): Target closed

Steps to Reproduce the Bug or Issue

I cannot repeat it, I do not know the reason for its appearance

Relevant Code

No response

Browser Type

Other (please write in Additional Context)

WhatsApp Account Type

Standard

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

"puppeteer": "^10.4.0", npm - 7.5.1, node - v15.8.0, "whatsapp-web.js": "^1.16.5"

Additional context

I do not know the browser version, I am connecting to puppeteer

sorry for the small amount of information and my English, I'm new to all this

me facing the same issues

priti0802 avatar Apr 07 '22 04:04 priti0802

me facing the same issues

RafaelIngenium avatar Apr 07 '22 17:04 RafaelIngenium

I think it's chromium, when exiting it, it somehow breaks the sessions folder and saves only qr, but I don't understand when I exit it if I have a beta whatsapp and my client is always active

rushan21pink avatar Apr 08 '22 12:04 rushan21pink

I'm having the same problem. Any ideias how to workaround or a fix? image

Felipedelima123 avatar Apr 11 '22 12:04 Felipedelima123

Has anyone found a solution for this? For me it happens when I send an audio

josep112 avatar Apr 20 '22 11:04 josep112

@pedroslopez can you think of an ideal solution here? what if we catch everything, then, if it matches this error here then we ignore otherwise we throw?

purpshell avatar Apr 21 '22 23:04 purpshell

Same issues. Has anyone found a solution for this?

onurguven avatar Apr 24 '22 15:04 onurguven

Same here. I'm using NestJS and whenever I refresh the server (with watch-mode on. i.e npm run start:dev) I get this error ( (Runtime.callFunctionOn): Target closed ) Plus NestJS throws a listen EADDRINUSE: address already in use :::8080. (8080 is an example, bcos any port results with this error) It seems like whatsapp-web.js takes NestJS's port, and then on refresh the NestJS' port is already in use. I can't figure it out, I'd appreciate any help with both errors. (I tried changing NestJS's port - it still throws a already in use error)

shanike avatar May 02 '22 12:05 shanike

Same issue here (when using client.destroy(). Has anyone found a solution?

gentil-eilison avatar Jun 21 '22 20:06 gentil-eilison

same here, need a workaround. anyone ?

justoverclockl avatar Jul 20 '22 08:07 justoverclockl

I was facing this too, when I use headless: false. Then I removed the single-process argument and it worked fine.

bernardoely avatar Jul 23 '22 19:07 bernardoely

now I faced this with headless: true + single-process. Disabling single-process now to see how it goes...

bernardoely avatar Aug 01 '22 19:08 bernardoely

This error is caused because of the destroy function

adding a catch to .initialize() like this would be a workaround for now


client.initialize().catch(_ => _)

purpshell avatar Aug 04 '22 00:08 purpshell

I am using the catch since several months and still having the issue :(

The browser randomly closes and the session gets lost...

luiscuriel avatar Aug 05 '22 06:08 luiscuriel

Same issue here, someone found a solution?

mnop1122 avatar Apr 19 '23 07:04 mnop1122

Sure thing, but I would love to see a proper update on this if possible.

SannanOfficial avatar Aug 29 '23 05:08 SannanOfficial

Same issue here

bmmangukiya avatar Sep 01 '23 10:09 bmmangukiya

Same issue here

henrique-smr avatar Oct 04 '23 21:10 henrique-smr

I am having the same issue. @pedroslopez do you have any thoughts on this error?

mariabsouza avatar Nov 13 '23 21:11 mariabsouza