Skip to content

Execution context was destroyed after 2–10 hours (v1.34.4) + getLastMsgKeyForAction is not a function (v1.34.6) #127056

Description

@ahmedramzyon

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.

I am experiencing two related issues while running a WhatsApp automation bot using whatsapp-web.js.

1️⃣ On version 1.34.4

The bot runs normally, but after approximately 2–10 hours, it crashes with:

Error: Execution context was destroyed, most likely because of a navigation.
at rewriteError (...)
at async Client.inject (...)

2️⃣ After upgrading to 1.34.6

The previous crash disappears, but a new error appears immediately when sending messages:

TypeError: e.getLastMsgKeyForAction is not a function
at window.WWebJS.sendSeen
at Client.sendMessage

This occurs during sendMessage and appears related to sendSeen.

Expected Behavior

🔁 Steps to Reproduce
Issue 1 (v1.34.4)

Start the bot

Let it run normally

After 2–10 hours

Bot crashes with:

Execution context was destroyed, most likely because of a navigation.

Issue 2 (v1.34.6)

Upgrade to v1.34.6

Send a message using client.sendMessage() or message.reply()

Immediately crashes with:

e.getLastMsgKeyForAction is not a function

Stack trace points to:

window.WWebJS.sendSeen

Steps to Reproduce the Bug or Issue

🎯 Expected Behavior

The bot should remain stable for long-running sessions.

sendMessage should not throw internal WhatsApp function errors.

Internal WhatsApp Web changes should not break sendSeen.

🧠 Observations / Hypothesis

The long-session crash may be related to WhatsApp Web reloading internally.

The getLastMsgKeyForAction error seems caused by a recent WhatsApp Web internal change.

The issue appears inside sendSeen before message sending.

Possibly related to recent WhatsApp Web version update.

📋 Minimal Example

Basic sendMessage:

await client.sendMessage(chatId, "Test message");

or

await message.reply("Test reply");

Both can trigger the error in 1.34.6.

WhatsApp Account Type

WhatsApp Business

Browser Type

Google Chrome

Operation System Type

Windows

Phone OS Type

Android

WhatsApp-Web.js Version

1.34.4 (long session crash) 1.34.6 (sendSeen error)

WhatsApp Web Version

Latest (bundled with Chromium)

Node.js Version

v18.20.8

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