Skip to content

Fix: getChat & getChats & getChatModal & getChatById (clean solution)#201854

Closed
DnTora wants to merge 1 commit into
wwebjs:mainfrom
DnTora:main
Closed

Fix: getChat & getChats & getChatModal & getChatById (clean solution)#201854
DnTora wants to merge 1 commit into
wwebjs:mainfrom
DnTora:main

Conversation

@DnTora

@DnTora DnTora commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR fixes an issue where getChat & getChats & getChatModal & getChatById could fail with a minified Puppeteer Evaluation failed error if a chat's lastReceivedKey did not contain a valid message identifier.

Root Cause

getChatModel() resolves lastMessage by reading the message referenced by lastReceivedKey.

When the message identifier is empty or undefined, the underlying IndexedDB lookup (IDBObjectStore.get()) throws a DataError, which propagates out of getChatModel() and causes getChats() / getChatById() to fail.

Changes
Validate that lastReceivedKey contains a valid message identifier before attempting the lookup.
Wrap the message lookup in try/catch.
Return lastMessage: null when the message cannot be resolved instead of throwing.
Result
No behavior changes for chats with valid lastReceivedKey values.
Chats with invalid or missing message identifiers no longer fail the entire request.
getChats() and getChatById() now return successfully, with lastMessage: null when appropriate.
Validation

✅ JavaScript syntax verified.
✅ Tested against a live WhatsApp session.
✅ getChats() and message retrieval now succeed for chats that previously caused the request to fail.

@github-actions github-actions Bot added api changes API modifications utility Utility code labels Jul 20, 2026
Squashed from 3 commits: initial fix, merge commit, and lint fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api changes API modifications utility Utility code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant