-
Couldn't load subscription status.
- Fork 4.7k
Feat/esm migration and performance optimization #2135
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
base: develop
Are you sure you want to change the base?
Feat/esm migration and performance optimization #2135
Conversation
- Updated subproject reference in evolution-manager-v2. - Replaced old JavaScript and CSS asset files with new versions for improved performance and styling. - Added new CSS file for consistent font styling across the application. - Updated the evolution logo image to the latest version.
- Added features for Chatwoot enhancements, participants data handling, and LID to phone number conversion. - Updated Docker configurations to include Kafka and frontend services. - Fixed PostgreSQL migration errors and improved message handling in Baileys and Chatwoot services. - Refactored TypeScript build process and implemented exponential backoff patterns.
- Updated the release date for version 2.3.5 to 2025-10-15. - Adjusted subproject reference in evolution-manager-v2 to the latest commit.
- Integrated telemetry logging for received messages in Evolution, WhatsApp Business, and Baileys services. - Enhanced message tracking by sending the message type to the telemetry system for better observability.
- Updated subproject reference in evolution-manager-v2 to the latest commit. - Enhanced the manager_install.sh script to include npm install and build steps for the evolution-manager-v2. - Replaced old JavaScript asset file with a new version for improved performance. - Added a new CSS file for consistent styling across the application.
Reviewer's GuideMigrates the codebase to ES Modules and refactors Chatwoot and WhatsApp integrations with enhanced validation, error handling, updated connection settings, and reduced processing delays to optimize performance and compatibility. Sequence diagram for createChatwoot with enhanced validation and error handlingsequenceDiagram
participant User
participant ChatwootController
participant ConfigService
participant ChatwootService
participant waMonitor
User->>ChatwootController: Request createChatwoot(instance, data)
ChatwootController->>ConfigService: get('CHATWOOT').ENABLED
ChatwootController->>ChatwootController: Validate data fields
alt Validation fails
ChatwootController-->>User: Throw BadRequestException
else Validation passes
ChatwootController->>ChatwootService: create(instance, data)
ChatwootService->>waMonitor: waInstances[instance.instanceName].setChatwoot(data)
ChatwootController->>ConfigService: get('SERVER').URL
ChatwootController-->>User: Return result with webhook_url
end
Sequence diagram for improved message processing and retry logicsequenceDiagram
participant BaileysMessageProcessor
participant ProcessorLogs
participant MessageBatch
BaileysMessageProcessor->>MessageBatch: Process batch
alt Error occurs
BaileysMessageProcessor->>ProcessorLogs: warn("Retrying message batch due to error")
BaileysMessageProcessor->>MessageBatch: Retry after 200ms (reduced delay)
end
Sequence diagram for receiveWebhook with removed delaysequenceDiagram
participant ChatwootService
participant ClientCw
participant Instance
participant Body
ChatwootService->>ClientCw: clientCw(instance)
ClientCw->>ChatwootService: Process webhook (no fixed delay)
ChatwootService-->>ClientCw: Immediate response
Class diagram for updated ChatwootController and ChatwootServiceclassDiagram
class ChatwootController {
+createChatwoot(instance: InstanceDto, data: ChatwootDto)
+findChatwoot(instance: InstanceDto): ChatwootDto
+findChatwootWebhookUrl(instance: InstanceDto): string
+receiveWebhook(instance: InstanceDto, data: any)
}
class ChatwootService {
+create(instance: InstanceDto, data: ChatwootDto)
+find(instance: InstanceDto): ChatwootDto
+receiveWebhook(instance: InstanceDto, body: any)
+eventWhatsapp(...)
}
ChatwootController --> ChatwootService: uses
ChatwootService --> waMonitor: uses
waMonitor --> waInstances: contains
waInstances --> BaileysStartupService: contains
BaileysStartupService --> ChatwootService: uses
Class diagram for BaileysStartupService changesclassDiagram
class BaileysStartupService {
+client: any
+configService: ConfigService
+localChatwoot: ChatwootDto
+chatwootService: ChatwootService
+baileysGenerateMessageTag()
+baileysSignalRepositoryDecryptMessage(jid, type, ciphertext)
}
BaileysStartupService --> ChatwootService: uses
BaileysStartupService --> ConfigService: uses
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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 there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/api/integrations/chatbot/chatwoot/services/chatwoot.service.ts:119-121` </location>
<code_context>
+- await this.waMonitor.waInstances[instance.instanceName].setChatwoot(data);
++ const waInstance = this.waMonitor.waInstances[instance.instanceName];
++
++ if (!waInstance) {
++ this.logger.error(`Instance ${instance.instanceName} not found`);
++ throw new Error(`Instance ${instance.instanceName} not found`);
++ }
++
</code_context>
<issue_to_address>
**suggestion:** Error thrown for missing waInstance could be more specific.
Using a custom error type like NotFoundError or BadRequestException will make it easier to handle this specific case and improve clarity for error consumers.
Suggested implementation:
```typescript
++ if (!waInstance) {
++ this.logger.error(`Instance ${instance.instanceName} not found`);
++ throw new NotFoundException(`Instance ${instance.instanceName} not found`);
++ }
```
```typescript
import { NotFoundException } from '@nestjs/common';
```
</issue_to_address>
### Comment 2
<location> `src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts:3401` </location>
<code_context>
+
+ if (normalNumbersNotInCache.length > 0) {
+ this.logger.verbose(`Checking ${normalNumbersNotInCache.length} numbers via Baileys (not found in cache)`);
+- verify = await this.client.onWhatsApp(...normalNumbersNotInCache);
++ verify = (await this.client.onWhatsApp(...normalNumbersNotInCache)) as any;
+ }
+
</code_context>
<issue_to_address>
**suggestion:** Casting to 'any' may hide type issues.
Consider specifying the expected type for the result of onWhatsApp instead of casting to 'any' to preserve type safety.
Suggested implementation:
```typescript
verify = (await this.client.onWhatsApp(...normalNumbersNotInCache)) as WhatsAppVerificationResult[];
```
You will need to ensure that the type `WhatsAppVerificationResult` (or the correct expected type) is defined and imported in this file. If the type is not already defined, create an appropriate interface or type alias that matches the structure returned by `onWhatsApp`.
</issue_to_address>Help me be more useful! Please click π or π on each comment and I'll use the feedback to improve your reviews.
| if (!waInstance) { | ||
| this.logger.error(`Instance ${instance.instanceName} not found`); | ||
| throw new Error(`Instance ${instance.instanceName} not found`); |
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.
suggestion: Error thrown for missing waInstance could be more specific.
Using a custom error type like NotFoundError or BadRequestException will make it easier to handle this specific case and improve clarity for error consumers.
Suggested implementation:
++ if (!waInstance) {
++ this.logger.error(`Instance ${instance.instanceName} not found`);
++ throw new NotFoundException(`Instance ${instance.instanceName} not found`);
++ }import { NotFoundException } from '@nestjs/common';β¦ with concurrency 3)
- Add Vue.js QR code scanner interface in dist_extensions/ - Configure Express to serve static files from dist_extensions/ at /qrcode route - Add comprehensive QR code documentation in docs/scan_qrcode/ - Include nginx configuration examples and setup guides - Add documentation for editMessage feature BREAKING CHANGE: QR code interface now served as separate Vue.js SPA at /qrcode/ endpoint
π Description
π Related Issue
Closes #(issue_number)
π§ͺ Type of Change
π§ͺ Testing
πΈ Screenshots (if applicable)
β Checklist
π Additional Notes
Summary by Sourcery
Migrate the codebase to ES modules, update build configuration, enforce stronger input validation and error handling, and optimize performance by reducing various delays and tuning timeouts across Chatwoot and WhatsApp integrations.
Bug Fixes:
Enhancements:
Build:
Documentation: