Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(engine): log the no-LID send retry so a possible duplicate is visible (#855)
Yudhi Armyndharisf73ca3dbdd20
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 755fcea6a..efae0eef7 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -9,6 +9,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Fixed+- **A message send that is retried after a recipient-address change is now recorded in the log.** When+ whatsapp-web.js reports that a contact's cached address is stale, the gateway re-resolves the address+ and sends again. That retry was silent, so in the case where the engine reports a failure for a+ message it had in fact already delivered, the resulting second copy appeared nowhere in the logs and+ could only be noticed on the recipient's phone. The retry now logs a warning naming the chat and both+ addresses. Sending behaviour is unchanged.+- **The login screen shows the gateway's actual version again.** The dashboard resolved its versionfrom whichever `package.json` sat in the working directory the build ran from, which meant`dashboard/package.json` — a file a release never touches — rather than the root `package.json` thatdiff --git a/src/engine/adapters/whatsapp-web-js.adapter.ts b/src/engine/adapters/whatsapp-web-js.adapter.tsindex 9a3b2b905..3271a9e98 100644--- a/src/engine/adapters/whatsapp-web-js.adapter.ts+++ b/src/engine/adapters/whatsapp-web-js.adapter.ts@@ -1456,6 +1456,13 @@ export class WhatsAppWebJsAdapter extends EventEmitter implements IWhatsAppEnginif (fresh === to) {throw err;}+ // The first send threw, but wwjs can throw after the message is already on the wire — so this+ // retry may produce a duplicate. Log it: without this the second copy is invisible.+ this.logger.warn('Send retried against a re-resolved id after "No LID for user"; may duplicate', {+ chatId,+ staleId: to,+ freshId: fresh,+ });return send(fresh);}}