fix(bot): align nested tsconfig base paths#482
Conversation
Greptile SummaryThis PR corrects the
Confidence Score: 3/5Safe to merge the tsconfig and Baileys API changes, but the WhatsApp bot will still fail to persist auth credentials across restarts because the stub auth state is never replaced with the real Baileys implementation. The tsconfig path corrections are straightforward and correct. The Baileys socket API fix is also correct. However, the stated goal of persisting credentials via creds.update is not achieved - saveState remains a no-op stub, so the bot will require a QR re-scan every time it restarts. packages/bot/whatsapp/src/index.ts - the local useMultiFileAuthState stub needs to be replaced with the real import from the baileys package Important Files Changed
Sequence DiagramsequenceDiagram
participant App
participant WhatsAppBot
participant Baileys as makeBaileysBot
participant AuthStub as useMultiFileAuthState (stub)
participant Disk
App->>WhatsAppBot: start()
WhatsAppBot->>AuthStub: useMultiFileAuthState("./auth")
AuthStub-->>WhatsAppBot: "{ state: {}, saveState: noop }"
Note over AuthStub,Disk: Disk is never read - state is always empty
WhatsAppBot->>Baileys: "makeBaileysBot({ auth: state, browser })"
Baileys-->>WhatsAppBot: sock (WASocket)
WhatsAppBot->>WhatsAppBot: sock.ev.on(creds.update, saveState)
Note over WhatsAppBot: saveState is a no-op - nothing is written
Baileys-->>WhatsAppBot: creds.update event
WhatsAppBot->>AuthStub: saveState()
AuthStub-->>Disk: no-op - nothing written
Baileys-->>WhatsAppBot: messages.upsert event
WhatsAppBot->>App: handler(IncomingMessage)
Reviews (1): Last reviewed commit: "fix(bot): align nested tsconfig base pat..." | Re-trigger Greptile |
| function useMultiFileAuthState( | ||
| dir: string | ||
| ): { state: any; saveState: () => void } { | ||
| return { | ||
| state: {}, | ||
| saveState: () => {}, | ||
| }; | ||
| } |
There was a problem hiding this comment.
useMultiFileAuthState stub silently discards all credentials
The local stub always returns state: {} (so Baileys starts unauthenticated on every launch) and saveState: () => {} (a no-op). Wiring creds.update to this callback — one of the stated goals of the PR — will never actually persist credentials to disk, so the bot will require a fresh QR-code scan on every restart. Baileys exports the real useMultiFileAuthState from the "baileys" package; it should be imported rather than re-implemented here.
| async stop(): Promise<void> { | ||
| this.running = false; | ||
| } |
There was a problem hiding this comment.
stop() leaves the socket connection open
stop() flips this.running but never calls this.sock?.end() (or the equivalent Baileys close method). The underlying WebSocket stays connected and event listeners keep firing after stop() returns, which can cause unexpected behavior or resource leaks if start() is called again.
Fixes #452.
Summary:
Validation:
Submitted for the ugig bounty/gig: Need someone to test submit bugs and PRs to fix those bugs.
Solana wallet for bounty payout:
Dy4yMkjCfupxaURt6iTMUrxqSDEmAJPPkKF66QahxJZD