-
Notifications
You must be signed in to change notification settings - Fork 5.2k
fix(baileys): improve error logging for fetching latest WaWeb version #2360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
vduggen
wants to merge
2
commits into
EvolutionAPI:develop
Choose a base branch
from
vduggen:develop
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+5
−0
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds error-aware logging after fetching the latest WhatsApp Web (Baileys) version so failures in the version fetch are surfaced without changing existing behavior when the fetch succeeds. Sequence diagram for Baileys version fetch and error loggingsequenceDiagram
participant BaileysStartupService
participant BaileysLibrary as BaileysLibrary
participant Logger
BaileysStartupService->>BaileysLibrary: fetchLatestWaWebVersion()
BaileysLibrary-->>BaileysStartupService: baileysVersion(version, error?)
BaileysStartupService->>Logger: info("Baileys version: " + version.join('.'))
alt error present on baileysVersion
BaileysStartupService->>Logger: error("Fetch latest WaWeb version error: " + error.message)
else no error
BaileysStartupService->>Logger: info("Group Ignore: " + localSettings.groupsIgnore)
end
BaileysStartupService->>Logger: info("Group Ignore: " + localSettings.groupsIgnore)
Flow diagram for Baileys WaWeb version error-aware loggingflowchart TD
A[Start BaileysStartupService startup] --> B[Call fetchLatestWaWebVersion]
B --> C[Receive baileysVersion with version and optional error]
C --> D[Log info Baileys version]
D --> E{baileysVersion.error is not null?}
E -- Yes --> F[Log error Fetch latest WaWeb version error with error.message]
E -- No --> G[Skip error logging]
F --> H[Log info Group Ignore settings]
G --> H[Log info Group Ignore settings]
H --> I[Continue startup process]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey - I've found 1 issue, and left some high level feedback:
- Consider handling cases where
baileysVersion?.erroris not anErrorinstance (e.g., string or unknown) by safely stringifying it or using a type guard, instead of assuming.messageexists. - If your logger supports structured logging, it may be more useful to pass the full
errorobject (and possibly the requested version/URL) as metadata rather than only loggingerror.messagein the string.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider handling cases where `baileysVersion?.error` is not an `Error` instance (e.g., string or unknown) by safely stringifying it or using a type guard, instead of assuming `.message` exists.
- If your logger supports structured logging, it may be more useful to pass the full `error` object (and possibly the requested version/URL) as metadata rather than only logging `error.message` in the string.
## Individual Comments
### Comment 1
<location> `src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts:649-651` </location>
<code_context>
const log = `Baileys version: ${version.join('.')}`;
this.logger.info(log);
+ const error = baileysVersion?.error ?? null;
+ if (error) {
+ this.logger.error(`Fetch latest WaWeb version error: ${error.message}`);
+ }
+
</code_context>
<issue_to_address>
**suggestion:** Log the error object (and/or stack) in addition to the message for better diagnostics.
Currently only `error.message` is logged, which loses useful context (e.g. stack trace or custom fields on non-standard error objects). Instead, log the full error object and/or stack, e.g.:
```ts
const error = baileysVersion?.error;
if (error) {
this.logger.error('Fetch latest WaWeb version error', { error });
}
```
so failures in fetching the latest WaWeb version are easier to diagnose.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts
Outdated
Show resolved
Hide resolved
…etching latest WaWeb version
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📋 Description
Added error logging for WhatsApp Web version fetch operation to improve debugging capabilities. When the request to fetch the latest WhatsApp Web version fails (e.g., due to network issues, blocking, or API changes), the error is now logged with detailed information. This helps identify when Baileys might be using an outdated version due to fetch failures.
The change adds error detection and logging after the version fetch attempt, allowing developers to see:
🔗 Related Issue
🧪 Type of Change
🧪 Testing
Test Scenarios:
📸 Screenshots (if applicable)