Skip to content

Conversation

@doonfrs
Copy link

@doonfrs doonfrs commented Nov 25, 2025

WhatsApp Web recently updated and broke the isGroup property getter, causing infinite recursion when accessed. This resulted in:

  • RangeError: Maximum call stack size exceeded
  • All message sending operations failing
  • Chat operations throwing stack overflow errors

Root cause: PR #3078 changed from functions.getIsGroup to chat.id.isGroup() which creates infinite recursion when accessing the property.

Fix: Check chat ID format directly instead of calling chat.id.isGroup()

  • Group IDs end with @g.us
  • Contact IDs end with @c.us
  • Avoids the recursive property access that causes the stack overflow

Tested with unminified build and verified message sending works correctly for all chat types (contacts, groups, and newsletters/channels).

WhatsApp Web recently updated and broke the isGroup property getter,
causing infinite recursion when accessed. This resulted in:
- RangeError: Maximum call stack size exceeded
- All message sending operations failing
- Chat operations throwing stack overflow errors

Root cause: PR wppconnect-team#3078 changed from functions.getIsGroup to chat.id.isGroup()
which creates infinite recursion when accessing the property.

Fix: Check chat ID format directly instead of calling chat.id.isGroup()
- Group IDs end with @g.us
- Contact IDs end with @c.us
- Avoids the recursive property access that causes the stack overflow

Tested with unminified build and verified message sending works correctly
for all chat types (contacts, groups, and newsletters/channels).
@manfe
Copy link
Contributor

manfe commented Nov 25, 2025

please add here the results:

WPP.conn.getBuildConstants()

Also

Which functions you are using to trigger the infinite loop

@AbdulQadhir
Copy link

AbdulQadhir commented Nov 25, 2025

Hi @manfe, I'm experiencing the exact same issue described in this PR. Here are the details you requested:

Functions Triggering Infinite Loop:

The infinite recursion occurs when calling:

  • WPP.chat.sendTextMessage() with any contact ID
  • Both with createChat: true and createChat: false
  • Affects both @s.whatsapp.net and @c.us contact formats

Error Details:

  • Error: RangeError: Maximum call stack size exceeded
  • Location: getIsGroup function in wa-js.js:2:177519
  • Stack trace: Shows infinite recursion between t.get and getIsGroup

Reproduction Steps:

  1. Open WhatsApp Web
  2. Run in console:
const contact = "[email protected]"; 
window.WPP.chat.sendTextMessage(contact, "Test", {
  createChat: true,
  waitForAck: true
});

Environment:

WA-JS Version: 3.18.8
Browser: Chrome
OS: macOS 23.1.0
Extension: WTF Chrome Extension (bulk messaging)

Impact:

This completely breaks message sending functionality. All attempts to send messages fail with the stack overflow error.

The fix in this PR (checking ID format directly instead of calling chat.id.isGroup()) makes perfect sense and should resolve the issue. Looking forward to this being merged!

Thanks for working on this fix!

@doonfrs
Copy link
Author

doonfrs commented Nov 25, 2025

Build Constants


  WPP.conn.getBuildConstants()

  Result:
  {
    "VERSION_PRIMARY": "2",
    "VERSION_SECONDARY": "3000",
    "VERSION_TERTIARY": "1030354043",
    "VERSION_BASE": "2.3000.1030354043",
    "WINDOWS_BUILD": null,
    "WINDOWS_OFFLINE": false,
    "WINDOWS_BUILD_IS_BETA": false,
    "VERSION_BASE_WITH_WINDOWS_BUILD": "2.3000.1030354043",
    "PUSH_PHASE": "C3",
    "VERSION_STR": "2.3000.1030354043",
    "DYN_ORIGIN": "https://web.whatsapp.com/",
    "WEB_PUBLIC_PATH": "/",
    "BUILD_URL": "https://web.whatsapp.com/"
  }

WhatsApp Web Version: 2.3000.1030354043
WPPConnect-WA Version: 3.18.8


Functions Triggering the Infinite Loop

The infinite recursion occurs when any code tries to access the isGroup property on a ChatModel instance. Here are examples:

  1. WPP.chat.sendTextMessage()

const chat = await WPP.chat.get('[email protected]');
await WPP.chat.sendTextMessage(chat.id, 'Hello');
// ❌ RangeError: Maximum call stack size exceeded
Internally, sendTextMessage() accesses chat.isGroup, which triggers the recursion.

  1. Accessing chat.isGroup directly

const chat = await WPP.chat.get('[email protected]');
const isGroup = chat.isGroup;
// ❌ RangeError: Maximum call stack size exceeded

  1. Any code iterating through chats

const chats = await WPP.chat.list();
chats.forEach(chat => {
console.log(chat.isGroup); // ❌ RangeError
});

Root Cause

The bug was introduced in PR #3078 (line 180 in src/chat/patch.ts):

Before (working):
isGroup: (chat: ChatModel) => functions.getIsGroup(chat)

After (buggy):
isGroup: (chat: ChatModel) => chat.id.isGroup()

This creates infinite recursion because:

  1. ChatModel.prototype.isGroup is defined as a getter that calls the function
  2. The function tries to access chat.id.isGroup()
  3. WhatsApp Web's Wid.isGroup() internally accesses chat.isGroup property
  4. This triggers the getter again → infinite loop

Fix:
isGroup: (chat: ChatModel) => chat.id.toString().includes('@g.us')

This directly checks the ID string format, avoiding the circular dependency.

@manfe
Copy link
Contributor

manfe commented Nov 25, 2025

@doonfrs on latest nightly version I am not able to reproduce it.

WPP.chat.get("[email protected]")
{revisionNumber: 24, __x_stale: {}, __fired: null, __changes: null, __initialized: true, …}

Try with the new released version 3.19.0

@manfe
Copy link
Contributor

manfe commented Nov 25, 2025

@doonfrs did you have success with the new version?

@manfe
Copy link
Contributor

manfe commented Nov 26, 2025

Not having feedback until tomorrow (27/nov) and no one else reporting issue with infinite loop I will close this issue.

This should be fixed in versions 3.19.0 and 3.19.2

@manfe
Copy link
Contributor

manfe commented Nov 27, 2025

No interaction, closing it

@manfe manfe closed this Nov 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants