GithubHelp home page GithubHelp logo

Comments (24)

smashah avatar smashah commented on August 22, 2024

Hmm, not clear from this error log. Can you try to recreate it by resending the last message that was not received by sulla?

from wa-automate-nodejs.

dogcalas avatar dogcalas commented on August 22, 2024

There is not received message by sulla when the error comes up. I am monitoring on my phone all received message, and I notice the failure because the bot is not responding on an user message. From the last sent message by the bot to the error time there is a difference of 5 hours. The message without response came 8 hours later.

I need that if it fails, at least close the process to restart the container.

from wa-automate-nodejs.

mrbarnk avatar mrbarnk commented on August 22, 2024

Yea @dogcalas , same here. if it can crash the container and reload it. It would have been awesome.

from wa-automate-nodejs.

smashah avatar smashah commented on August 22, 2024

I'd love to add the functionality, I just need to be able to reproduce the issue

from wa-automate-nodejs.

mrbarnk avatar mrbarnk commented on August 22, 2024

Page crashed error, and I think you left a promise un cathed in the code. I think so.
whatsapp_1 | (node:1) 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(). (rejection id: 10) whatsapp_1 | (node:1) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

from wa-automate-nodejs.

mrbarnk avatar mrbarnk commented on August 22, 2024

Maybe there will be a watcher to let you know if the page has crashed. @smashah

I don't know any solution after that.

from wa-automate-nodejs.

smashah avatar smashah commented on August 22, 2024

Possibly this ? puppeteer/puppeteer#1030

from wa-automate-nodejs.

mrbarnk avatar mrbarnk commented on August 22, 2024

maybe so.

from wa-automate-nodejs.

mrbarnk avatar mrbarnk commented on August 22, 2024

@smashah you can check this out. https://stackoverflow.com/questions/57956697/unhandledpromiserejectionwarning-error-page-crashed-while-using-puppeteer

from wa-automate-nodejs.

smashah avatar smashah commented on August 22, 2024

@mrbarnk can you share your code so I can figure out how to reproduce this.

from wa-automate-nodejs.

mrbarnk avatar mrbarnk commented on August 22, 2024

I read your best practice, and I've tried adding await to all my codes now, let see how this goes.

Thanks @smashah

from wa-automate-nodejs.

smashah avatar smashah commented on August 22, 2024

@mrbarnk @dogcalas in v =1.6.6 you can now use client.kill()

This way you can control when a session is destroyed upon catch statements

e.g

...
try{
...
await client.sendMessage(...
...
} catch(error){
client.kill();
//maybe restart the session then
}

#68 (comment)

Hope that works for you. I'll close this for now. thanks

from wa-automate-nodejs.

dogcalas avatar dogcalas commented on August 22, 2024

Before write this issue all my awaits calls was between try-catch. Although, I still receiving this error, and never a catch section is executed. After 5 days without problems, boom, it happened again. Most weird is that the trace doesn't show any sulla files.

Just to know, what nodejs version are you using? I am using node:10-slim docker image.
@mrbarnk are you using WebSockets to do others things in your code?

from wa-automate-nodejs.

mrbarnk avatar mrbarnk commented on August 22, 2024

from wa-automate-nodejs.

smashah avatar smashah commented on August 22, 2024

From the error code, you can see that this error is happening onMessage so maybe you should try something like:

try{
client.onMessage(message=>{...})
} catch(error){
client.kill();
//maybe restart the session then
}

from wa-automate-nodejs.

mrbarnk avatar mrbarnk commented on August 22, 2024

I'm using client.sendText().

Please, guide me on this you posted.

from wa-automate-nodejs.

mrbarnk avatar mrbarnk commented on August 22, 2024

And again on the latest version, please set auto-refresh QR code to option.

So, we that do not need it will not be affected, sir.

Thanks!

from wa-automate-nodejs.

smashah avatar smashah commented on August 22, 2024

@mrbarnk in v1.6.10 you can now set autoRefresh:false when you start sulla.

https://github.com/smashah/sulla/blob/629f75969416cc4cf6c58cf45b004db1c9240e49/demo/index.ts#L108

from wa-automate-nodejs.

dogcalas avatar dogcalas commented on August 22, 2024

@smashah Today in the morning I received the same error, and sulla stop receiving messages. The only reason I can figure out, is a today change in whatsapp version.
I have noticed in my web browser when whatsapp is updated, this messages comes up.
image
Could this be the issue cause?

from wa-automate-nodejs.

smashah avatar smashah commented on August 22, 2024

@dogcalas possibly. Over the last 2 days they released version 0.4.613. Is it ok when u restart?

from wa-automate-nodejs.

dogcalas avatar dogcalas commented on August 22, 2024

Yes, it's ok, when I restart everything is working normally.

from wa-automate-nodejs.

mrbarnk avatar mrbarnk commented on August 22, 2024

When you run the sulla-hotfix on a server, after some hours or days, it goes crash! I don't seem to understand that.

and I think this is the possible fix for the problem sir.

https://stackoverflow.com/questions/57956697/unhandledpromiserejectionwarning-error-page-crashed-while-using-puppeteer

from wa-automate-nodejs.

mrbarnk avatar mrbarnk commented on August 22, 2024

Or from the whatsapp.ts or initializer.ts, whichever one what works, the class should have a method that kills the session and restarts it automatically.

In whatsapp.ts

public async reload() {
    console.log('Restarting node');
     if (this.page) await this.kill();
      // to recreate the sessionw when session get killed.
         await this.create(globalSession,globalpuppeteerConfigOverride,globalcustomUserAgent)
      return true;

In initialize.ts

public async reload() {
    console.log('Restarting node');

    await waPage.close();
    await waPage.browser().close();

Then the globalSession, globalpuppeteerConfigOverride and globalcustomUserAgent would have been stored when the create function was initaly initialized by us.

So like export async function create would be changed to

let globalSession,globalpuppeteerConfigOverride,globalcustomUserAgent;

export async function create(sessionId?: string, puppeteerConfigOverride?:any, customUserAgent?:string) {
  if (!sessionId) sessionId = 'session';
     globalSession = sessionId
     globalpuppeteerConfigOverride = puppeteerConfigOverride
     globalcustomUserAgent = customUserAgent

I think with this, the problem should be solved @smashah

from wa-automate-nodejs.

mrbarnk avatar mrbarnk commented on August 22, 2024

I saw something now,

like you have it in create function,

    spinner.fail('The session is invalid. Retrying')
    await kill()
    return await create(sessionId,puppeteerConfigOverride,customUserAgent);

You can just implement this in the public async reload() function which we just want to create to reload the session when page drops.

Those are three possible solutions I can give you for now.

from wa-automate-nodejs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.