Skip to content

Restore the bot when the server has been restarted. #5786

@CotulbeaCosmin

Description

@CotulbeaCosmin

Is there an existing issue for this?

  • I have searched the existing issues.

Is this a problem caused by your code, or is it specifically because of the library?

  • I have double-checked my code carefully.

Describe the bug.

Hello, I have the following issue: I activate the bot and save the session. I want to reload the bot from the session when the server is restarted, but I get this error:

Error initialize client:Failed to launch the browser process: Code: 21

stderr:

[14:14:0130/094243.901492:ERROR:chrome/browser/process_singleton_posix.cc:363] The profile appears to be in use by another Chromium process (140) on another computer (034287356bb6). Chromium has locked the profile so that it doesn't get corrupted. If you are sure no other processes are using this profile, you can unlock the profile and relaunch Chromium.

[14:14:0130/094243.909525:ERROR:chrome/browser/ui/views/message_box_dialog.cc:199] Unable to show message box: Google Chrome for Testing - The profile appears to be in use by another Chromium process (140) on another computer (034287356bb6). Chromium has locked the profile so that it doesn't get corrupted. If you are sure no other processes are using this profile, you can unlock the profile and relaunch Chromium.


Expected Behavior

I expect to be able to reuse the same session without having to activate the bot again.

Steps to Reproduce the Bug or Issue

This is my function for restore bot after the server is started:

function restoreBots() {
const sessionsDir = path.join(__dirname, 'sessions');
if (!fs.existsSync(sessionsDir)) return;

const folders = fs.readdirSync(sessionsDir).filter(folder => folder.startsWith('session-'));
folders.forEach(folder => {
    const botId = folder.replace('session-', '');
    createBot(botId, null, null)
        .catch(err => console.error(`❌ Failed to restore bot ${botId}:`, err.message));
});

}

WhatsApp Account Type

Standard

Browser Type

Chromium

Operation System Type

Linux | Docker + Debian

Phone OS Type

Android

WhatsApp-Web.js Version

github:timothydillan/whatsapp-web.js#fix/duplicate-events-and-bindings

WhatsApp Web Version

github:timothydillan/whatsapp-web.js#fix/duplicate-events-and-bindings

Node.js Version

v20.20.0

Authentication Strategy

LocalAuth

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions