Devlog #3
Today, I have finished Phase 2; and everything is working!
On top of finishing Phase 2, I have started the multi-user support which I have decided to add.
The Ship Tabacle
Before starting work on Phase 3, I ended up finding out from shipping guidelines that the project, quote “Bots (Discord, Slack, etc…): It has to be hosted! … You can’t leave your bot unhosted with only source code.”
Also implying that it has to be… “Multi-User” 
As a result of this, I have decided to add multi-user support, by giving one wwebjs Client to each user, managed by the new client manager: clientPool.js that allow’s everyone to have their own “instance,” group selection, and notifications.
The upside to this way of solving the problem is that most of the components, for example: Classifier, Alerts System, DB Schema, all of that can stay the same, only requiring a few changes to make it compatible for the new Multi User System.
With all of these changes; the new system to register and use the bot is this:
- User DMs the bot
/start - Bot asks for their WhatsApp number
- They reply with it
-
spawnClient(chatId, phone)is called - wwebjs emits
qr, we callrequestPairingCode(phone)instead of sending a QR image - The user receives a code like
ABCD-1234, enters it in WhatsApp → Linked Devices, anddd… - Connected ✅
This simlifies the bot to be User Friendly, to host, and use + allows me to still be able to ship 
Problems Encountered
1. “Houston! We have an IPv6 Problem…”
-
Problem:
bot.launch()was timing out during thegetMehandshake with Telegram at random. Worked sometimes, failed other times. - **Fix:**Added
require('dns').setDefaultResultOrder('ipv4first')onindex.js, plus akeepAliveHTTPS agent on the Telegraf instance.
2. “Silent Treatment”
-
Problem: Bot received
/start, asked for phone number, user replied… and you get ghosted. -
Fix: One missing
String()cast in/start. Took way too long to find.
3. “The Ghost of Chromium Past”
- Problem: Previous test run left a Chromium process hanging. Next launch: “The browser is already running for auth_data/session-7145622406.”
-
Fix:
pkill -f chromium+ delete the session folder.
4. “t”
-
Problem:
requestPairingCodethrew a single-letter minified error:t. No stack trace, no message. Just…t. -
Fix: Drop the alpha version, and pin the stable
2.3000.1017054665instead.
5. “The Error in the Error Handler’s House”
- Problem: After bug 4 threw, the catch block tried to DM the user an error message. That also timed out, with the SAME cold IPv6 issue, firing during Chromium’s initial page load which was already hammering the event loop.
-
Fix: Wrapped the notification send in its own
try/catch. A failed notification shouldn’t throw an unhandled rejection on top of the original error.
What’s Next
-
Finish commands:
/addgroup,/threshold,/categories,/status,/deals -
restoreAllSessions(): reconnect everyone on process restart -
messageHandler.js: wire live capture per subscriber -
sendDealAlert(): fan-out to all matching subscribers - Sold detection
- Dashboard post-ship
- First public ship