Title: Fix Chatwoot DB Connection Instability and Implement Stale Conversation Cache Handling by Vitordotpy · Pull Request #2017 · EvolutionAPI/evolution-api · GitHub
Open Graph Title: Fix Chatwoot DB Connection Instability and Implement Stale Conversation Cache Handling by Vitordotpy · Pull Request #2017 · EvolutionAPI/evolution-api
X Title: Fix Chatwoot DB Connection Instability and Implement Stale Conversation Cache Handling by Vitordotpy · Pull Request #2017 · EvolutionAPI/evolution-api
Description: This pull request addresses two critical issues in the Chatwoot integration to improve its reliability and resilience. It introduces on-demand database connections to prevent intermittent connection failures and implements a retry mechanism to handle stale conversation data cached in Redis. Fixes: Prevent Intermittent DB Connection Errors: Refactored the ChatwootService to initialize the PostgreSQL client on-demand (getPgClient) rather than at service instantiation. This resolves a race condition where the client could be created with an incorrect or default database connection string, causing sporadic database does not exist errors. Handle Stale Conversation Cache: Implemented a try-catch mechanism within the createMessage and sendData methods. When a 404 Not Found error is received from the Chatwoot API (indicating a stale conversation ID in the Redis cache), the system now automatically: Deletes the invalid conversation entry from Redis. Creates a new conversation in Chatwoot. Retries the original message-sending operation with the new, valid conversation ID. Enhancements: Increased Resilience: The integration is now more robust against temporary inconsistencies between the Redis cache and the Chatwoot database state, preventing message delivery failures. Improved Stability: Lazily initializing the database connection ensures that the correct, instance-specific credentials are used for every operation, eliminating a significant source of production errors. Summary This PR resolves critical stability issues in the Chatwoot integration by implementing on-demand database connections to fix intermittent connection errors and adding a retry mechanism that automatically handles stale conversation IDs from the Redis cache, ensuring more reliable message delivery. Summary by Sourcery Fix intermittent database connection errors and add automatic retry handling for stale Chatwoot conversation IDs by lazily initializing the Postgres client and evicting and recreating conversations on 404 errors. Bug Fixes: Prevent intermittent 'database does not exist' errors by initializing the PostgreSQL client on-demand. Enhancements: Automatically detect and recover from stale Chatwoot conversation IDs by evicting the Redis cache entry, creating a new conversation, and retrying message operations.
Open Graph Description: This pull request addresses two critical issues in the Chatwoot integration to improve its reliability and resilience. It introduces on-demand database connections to prevent intermittent connectio...
X Description: This pull request addresses two critical issues in the Chatwoot integration to improve its reliability and resilience. It introduces on-demand database connections to prevent intermittent connectio...
Opengraph URL: https://github.com/EvolutionAPI/evolution-api/pull/2017
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/checks(.:format) |
| route-controller | pull_requests |
| route-action | checks |
| fetch-nonce | v2:41c52151-c64f-4d54-2911-8275b69247b3 |
| current-catalog-service-hash | 87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a |
| request-id | 9166:1B51C4:2835489:35C0B03:6992F050 |
| html-safe-nonce | db4dbe9378a859331fc1786fbe2e12dd104db00f33fce53897f302195c2811d7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MTY2OjFCNTFDNDoyODM1NDg5OjM1QzBCMDM6Njk5MkYwNTAiLCJ2aXNpdG9yX2lkIjoiNjk1Mzg5NzM2OTM2NTgzNTg1NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b2f6c98d2ba92c458bd9bc8c23d88cb259e37c777da49d0820cbbd0a6c6a395b |
| hovercard-subject-tag | pull_request:2861870529 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/EvolutionAPI/evolution-api/pull/2017/checks |
| twitter:image | https://avatars.githubusercontent.com/u/72520858?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/72520858?s=400&v=4 |
| og:image:alt | This pull request addresses two critical issues in the Chatwoot integration to improve its reliability and resilience. It introduces on-demand database connections to prevent intermittent connectio... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 01ab16879a3159e6f0717ab948b9b562e162a6aafd1f4393b786b07b747df244 |
| turbo-cache-control | no-preview |
| go-import | github.com/EvolutionAPI/evolution-api git https://github.com/EvolutionAPI/evolution-api.git |
| octolytics-dimension-user_id | 136080052 |
| octolytics-dimension-user_login | EvolutionAPI |
| octolytics-dimension-repository_id | 651487266 |
| octolytics-dimension-repository_nwo | EvolutionAPI/evolution-api |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 651487266 |
| octolytics-dimension-repository_network_root_nwo | EvolutionAPI/evolution-api |
| turbo-body-classes | logged-out env-production page-responsive full-width full-width-p-0 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b1570f3928bef80fa5fc7890ce0942e9b696ad9d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width