chore: add connection/send logs and web error surfacing

This commit is contained in:
Peter Steinberger
2025-11-25 05:10:19 +01:00
parent 35d7fe7fc7
commit a9533d0999
2 changed files with 14 additions and 8 deletions

View File

@@ -39,14 +39,19 @@ export async function sendCommand(
if (waitSeconds !== 0) {
runtime.log(info("Wait/poll are Twilio-only; ignored for provider=web."));
}
const res = await deps.sendMessageWeb(
opts.to,
opts.message,
{
verbose: false,
mediaUrl: opts.media,
},
);
const res = await deps
.sendMessageWeb(
opts.to,
opts.message,
{
verbose: false,
mediaUrl: opts.media,
},
)
.catch((err) => {
runtime.error(`❌ Web send failed: ${String(err)}`);
throw err;
});
if (opts.json) {
runtime.log(
JSON.stringify(

View File

@@ -106,6 +106,7 @@ export async function sendMessageWeb(
): Promise<{ messageId: string; toJid: string }> {
const sock = await createWaSocket(false, options.verbose);
try {
logInfo("🔌 Connecting to WhatsApp Web…");
await waitForWaConnection(sock);
const jid = toWhatsappJid(to);
try {