From f3fe019e3d40c2d7c021d3e01960d4e58ac24057 Mon Sep 17 00:00:00 2001 From: khhjoe Date: Wed, 25 Mar 2026 11:05:43 +0800 Subject: [PATCH] fix(whatsapp): use async fs.promises.readFile for selfLid creds read --- extensions/whatsapp/src/inbound/monitor.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/extensions/whatsapp/src/inbound/monitor.ts b/extensions/whatsapp/src/inbound/monitor.ts index 4026ae8a32f..313a155c602 100644 --- a/extensions/whatsapp/src/inbound/monitor.ts +++ b/extensions/whatsapp/src/inbound/monitor.ts @@ -82,10 +82,11 @@ export async function monitorWebInbox(options: { // Bot's own LID (Linked Identity) — needed for reply-to-bot detection // when contextInfo.participant returns a LID instead of a phone JID. // Baileys 7 rc9 does not expose lid on sock.user, so read from creds file. - const selfLid = (() => { + const selfLid = await (async () => { try { - const credsPath = path.join(options.authDir ?? "", "creds.json"); - const creds = JSON.parse(fs.readFileSync(credsPath, "utf-8")); + const credsPath = path.join(options.authDir, "creds.json"); + const raw = await fs.promises.readFile(credsPath, "utf-8"); + const creds = JSON.parse(raw) as { me?: { lid?: string } }; return creds?.me?.lid ?? undefined; } catch { return (sock.user as { lid?: string } | undefined)?.lid ?? undefined;