Skip to content

Commit 7b2249c

Browse files
test(gateway): update fanout assertions to match concurrency-1 + stagger contract
The previous assertions in `limits whole-channel account startup fanout to four` and `limits channel plugin startup fanout to four` expected `maxActive == 4` under the old `CHANNEL_STARTUP_CONCURRENCY = 4` contract. With this PR's serialization (concurrency 1, 3s handoff stagger), only one preflight runs at a time, so the tests are renamed and rewritten to walk through the staggered handoffs and verify single-active behavior plus per-account stagger calls. Also adds the user-facing CHANGELOG entry the bot requested. Addresses ClawSweeper P2 + P3 review findings on PR #78437.
1 parent ec96d1f commit 7b2249c

2 files changed

Lines changed: 42 additions & 27 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ Docs: https://docs.openclaw.ai
109109

110110
### Fixes
111111

112+
- Gateway/channels: serialize channel and account startup with a 3-second handoff stagger and defer primary model prewarm until after `startChannels()` completes, preventing simultaneous Telegram `getMe` calls and provider-runtime imports from starving the Node event loop. Multi-account hosts (especially Windows 11 + Node 24 with 5+ Telegram accounts) saw multi-minute polling stalls on startup. (#78437) Thanks @glasswings-lang.
112113
- Google Meet/Voice Call: wait longer before playing PIN-derived Twilio DTMF for Meet dial-in prompts and retire stale delegated phone sessions instead of reusing completed calls.
113114
- Onboard/channels: recover externalized channel plugins from stale `channels.<id>` config by falling back to `ensureChannelSetupPluginInstalled` via the trusted catalog when the plugin is missing on disk, so leftover `appId`/token entries no longer dead-end onboard with "<channel> plugin not available." (#78328) Thanks @sliverp.
114115
- Codex/app-server: forward the OpenClaw workspace bootstrap block through Codex `developerInstructions` instead of `config.instructions`, so persona/style guidance reaches the behavior-shaping app-server lane. Fixes #77363. Thanks @lonexreb.

‎src/gateway/server-channels.test.ts‎

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -717,8 +717,8 @@ describe("server-channels auto restart", () => {
717717
);
718718
});
719719

720-
it("limits whole-channel account startup fanout to four", async () => {
721-
const accountIds = ["one", "two", "three", "four", "five", "six"];
720+
it("serializes whole-channel account startup with handoff stagger", async () => {
721+
const accountIds = ["one", "two", "three"];
722722
const releases: Array<() => void> = [];
723723
let active = 0;
724724
let maxActive = 0;
@@ -749,28 +749,38 @@ describe("server-channels auto restart", () => {
749749
const start = manager.startChannel("discord");
750750
await flushMicrotasks();
751751

752-
expect(isConfigured).toHaveBeenCalledTimes(4);
753-
expect(maxActive).toBe(4);
752+
// Concurrency is now 1: only the first account's preflight runs.
753+
expect(isConfigured).toHaveBeenCalledTimes(1);
754+
expect(maxActive).toBe(1);
754755
expect(startAccount).not.toHaveBeenCalled();
755756

756-
releases.splice(0, 4).forEach((release) => release());
757-
await waitForMicrotaskCondition(
758-
() => isConfigured.mock.calls.length === 6,
759-
"expected second account startup wave",
760-
);
761-
762-
expect(isConfigured).toHaveBeenCalledTimes(6);
763-
expect(maxActive).toBe(4);
757+
// Walk through all three accounts: release preflight, advance through
758+
// the stagger sleep, and confirm only one is active at any time.
759+
for (let i = 0; i < accountIds.length; i += 1) {
760+
releases.shift()?.();
761+
await flushMicrotasks();
762+
// Stagger sleep happens after handoff inside the inner task; advance
763+
// past it so the limiter picks up the next account.
764+
await vi.advanceTimersByTimeAsync(3_000);
765+
await flushMicrotasks();
766+
}
764767

765-
releases.splice(0).forEach((release) => release());
766768
await start;
767-
expect(startAccount).toHaveBeenCalledTimes(6);
769+
expect(isConfigured).toHaveBeenCalledTimes(3);
770+
expect(startAccount).toHaveBeenCalledTimes(3);
771+
expect(maxActive).toBe(1);
772+
// sleepWithAbort(3_000, ...) is called once per account-handoff stagger.
773+
expect(
774+
hoisted.sleepWithAbort.mock.calls.filter(
775+
([ms]) => ms === 3_000,
776+
),
777+
).toHaveLength(3);
768778

769779
await manager.stopChannel("discord");
770780
});
771781

772-
it("limits channel plugin startup fanout to four", async () => {
773-
const channelIds = Array.from({ length: 6 }, (_, index) => `test-${index}` as ChannelId);
782+
it("serializes channel plugin startup with handoff stagger", async () => {
783+
const channelIds = Array.from({ length: 3 }, (_, index) => `test-${index}` as ChannelId);
774784
const releases: Array<() => void> = [];
775785
let active = 0;
776786
let maxActive = 0;
@@ -799,20 +809,24 @@ describe("server-channels auto restart", () => {
799809
const start = manager.startChannels();
800810
await flushMicrotasks();
801811

802-
expect(releases).toHaveLength(4);
803-
expect(maxActive).toBe(4);
812+
// Concurrency is 1: only the first plugin's preflight runs.
813+
expect(releases).toHaveLength(1);
814+
expect(maxActive).toBe(1);
804815

805-
releases.splice(0, 4).forEach((release) => release());
806-
await waitForMicrotaskCondition(
807-
() => releases.length === 2,
808-
"expected second channel startup wave",
809-
);
810-
811-
expect(releases).toHaveLength(2);
812-
expect(maxActive).toBe(4);
816+
for (let i = 0; i < channelIds.length; i += 1) {
817+
releases.shift()?.();
818+
await flushMicrotasks();
819+
await vi.advanceTimersByTimeAsync(3_000);
820+
await flushMicrotasks();
821+
}
813822

814-
releases.splice(0).forEach((release) => release());
815823
await start;
824+
expect(maxActive).toBe(1);
825+
expect(
826+
hoisted.sleepWithAbort.mock.calls.filter(
827+
([ms]) => ms === 3_000,
828+
),
829+
).toHaveLength(3);
816830

817831
await Promise.all(channelIds.map((id) => manager.stopChannel(id)));
818832
});

0 commit comments

Comments
 (0)