惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
Google DeepMind News
Google DeepMind News
MyScale Blog
MyScale Blog
A
About on SuperTechFans
Martin Fowler
Martin Fowler
M
MIT News - Artificial intelligence
Recent Announcements
Recent Announcements
D
DataBreaches.Net
B
Blog
博客园 - 【当耐特】
爱范儿
爱范儿
有赞技术团队
有赞技术团队
P
Proofpoint News Feed
WordPress大学
WordPress大学
小众软件
小众软件
Apple Machine Learning Research
Apple Machine Learning Research
I
InfoQ
Engineering at Meta
Engineering at Meta
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Last Week in AI
Last Week in AI
Microsoft Azure Blog
Microsoft Azure Blog
雷峰网
雷峰网
量子位
G
Google Developers Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(whatsapp): bound group metadata cache expiry · opencl...
steipete · 2026-05-30 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -10,7 +10,11 @@ import { recordChannelActivity } from "openclaw/plugin-sdk/channel-activity-runt

1010

import { formatLocationText } from "openclaw/plugin-sdk/channel-inbound";

1111

import { createInboundDebouncer } from "openclaw/plugin-sdk/channel-inbound-debounce";

1212

import { getChildLogger } from "openclaw/plugin-sdk/logging-core";

13-

import { parseStrictFiniteNumber } from "openclaw/plugin-sdk/number-runtime";

13+

import {

14+

asDateTimestampMs,

15+

parseStrictFiniteNumber,

16+

resolveExpiresAtMsFromDurationMs,

17+

} from "openclaw/plugin-sdk/number-runtime";

1418

import { defaultRuntime } from "openclaw/plugin-sdk/runtime-env";

1519

import { createSubsystemLogger } from "openclaw/plugin-sdk/runtime-env";

1620

import { uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";

@@ -80,6 +84,13 @@ type LocalGroupMetadataCacheEntry = WhatsAppGroupMetadataCacheEntry & {

8084

mentionParticipants?: WhatsAppOutboundMentionParticipant[];

8185

};

8286
87+

function resolveGroupMetadataExpiresAt(nowRaw = Date.now()): number | undefined {

88+

const now = asDateTimestampMs(nowRaw);

89+

return now === undefined

90+

? undefined

91+

: resolveExpiresAtMsFromDurationMs(GROUP_META_TTL_MS, { nowMs: now });

92+

}

93+
8394

function parseWhatsAppTimestampSeconds(value: unknown): number | undefined {

8495

if (value == null) {

8596

return undefined;

@@ -96,6 +107,10 @@ function rememberGroupMetadataCacheEntry<T extends WhatsAppGroupMetadataCacheEnt

96107

jid: string,

97108

entry: T,

98109

): void {

110+

if (asDateTimestampMs(entry.expires) === undefined) {

111+

cache.delete(jid);

112+

return;

113+

}

99114

if (cache.has(jid)) {

100115

cache.delete(jid);

101116

}

@@ -118,7 +133,9 @@ function readGroupMetadataCacheEntry<T extends WhatsAppGroupMetadataCacheEntry>(

118133

if (!entry) {

119134

return null;

120135

}

121-

if (entry.expires <= Date.now()) {

136+

const now = asDateTimestampMs(Date.now());

137+

const expires = asDateTimestampMs(entry.expires);

138+

if (now === undefined || expires === undefined || expires <= now) {

122139

cache.delete(jid);

123140

return null;

124141

}

@@ -472,15 +489,15 @@ export async function attachWebInboxToSocket(

472489

subject: meta.subject,

473490

participants,

474491

mentionParticipants,

475-

expires: Date.now() + GROUP_META_TTL_MS,

492+

expires: resolveGroupMetadataExpiresAt() ?? 0,

476493

};

477494

};

478495
479496

const summarizeGroupMetaForReconnectCache = (

480497

meta: GroupMetadata,

481498

): WhatsAppGroupMetadataCacheEntry => ({

482499

subject: meta.subject,

483-

expires: Date.now() + GROUP_META_TTL_MS,

500+

expires: resolveGroupMetadataExpiresAt() ?? Number.NaN,

484501

});

485502
486503

const getGroupMeta = async (jid: string) => {

@@ -511,7 +528,7 @@ export async function attachWebInboxToSocket(

511528

options.verbose,

512529

`Failed to fetch group metadata for ${jid}: ${String(err)}`,

513530

);

514-

return { expires: Date.now() + GROUP_META_TTL_MS };

531+

return { expires: resolveGroupMetadataExpiresAt() ?? 0 };

515532

}

516533

};

517534
Original file line numberDiff line numberDiff line change

@@ -427,6 +427,35 @@ describe("web monitor inbox", () => {

427427

await listener.close();

428428

});

429429
430+

it("does not keep reconnect group metadata when the expiry would exceed a valid Date", async () => {

431+

const groupMetadataCache: NonNullable<InboxMonitorOptions["groupMetadataCache"]> = new Map();

432+

const dateNow = vi.spyOn(Date, "now").mockReturnValue(8_640_000_000_000_000);

433+

try {

434+

const sock = getSock();

435+

sock.groupFetchAllParticipating.mockResolvedValueOnce({

436+

"123@g.us": {

437+

id: "123@g.us",

438+

subject: "Boundary Group",

439+

owner: undefined,

440+

participants: [],

441+

},

442+

});

443+
444+

const { listener } = await startInboxMonitor(vi.fn(async () => {}) as InboxOnMessage, {

445+

groupMetadataCache,

446+

});

447+
448+

await vi.waitFor(() => {

449+

expect(sock.groupFetchAllParticipating).toHaveBeenCalledTimes(1);

450+

});

451+

expect(groupMetadataCache.has("123@g.us")).toBe(false);

452+
453+

await listener.close();

454+

} finally {

455+

dateNow.mockRestore();

456+

}

457+

});

458+
430459

it("does not block inbound listeners while group hydration is pending", async () => {

431460

let resolveHydration!: () => void;

432461

const sock = getSock();