Merge f43072f9551196447ba08b15b803a03d0f4965d3 into 598f1826d8b2bc969aace2c6459824737667218c

This commit is contained in:
Elliot Liu 2026-03-21 04:10:07 +00:00 committed by GitHub
commit 87b8b72385
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 19 additions and 11 deletions

View File

@ -44,8 +44,8 @@ async function waitForStartedAccount(started: string[], accountId: string) {
}
}
afterEach(() => {
stopFeishuMonitor();
afterEach(async () => {
await stopFeishuMonitor();
});
describe("Feishu monitor startup preflight", () => {

View File

@ -132,13 +132,15 @@ export function recordWebhookStatus(
});
}
export function stopFeishuMonitorState(accountId?: string): void {
export async function stopFeishuMonitorState(accountId?: string): Promise<void> {
if (accountId) {
wsClients.delete(accountId);
const server = httpServers.get(accountId);
if (server) {
server.close();
httpServers.delete(accountId);
await new Promise<void>((resolve) => {
server.close(() => resolve());
});
}
botOpenIds.delete(accountId);
botNames.delete(accountId);
@ -146,10 +148,16 @@ export function stopFeishuMonitorState(accountId?: string): void {
}
wsClients.clear();
const closePromises: Promise<void>[] = [];
for (const server of httpServers.values()) {
server.close();
closePromises.push(
new Promise<void>((resolve) => {
server.close(() => resolve());
}),
);
}
httpServers.clear();
await Promise.all(closePromises);
botOpenIds.clear();
botNames.clear();
}

View File

@ -90,6 +90,6 @@ export async function monitorFeishuProvider(opts: MonitorFeishuOpts = {}): Promi
await Promise.all(monitorPromises);
}
export function stopFeishuMonitor(accountId?: string): void {
stopFeishuMonitorState(accountId);
export async function stopFeishuMonitor(accountId?: string): Promise<void> {
await stopFeishuMonitorState(accountId);
}

View File

@ -58,8 +58,8 @@ async function postSignedPayload(url: string, payload: Record<string, unknown>)
});
}
afterEach(() => {
stopFeishuMonitor();
afterEach(async () => {
await stopFeishuMonitor();
});
describe("Feishu webhook signed-request e2e", () => {

View File

@ -35,9 +35,9 @@ import {
stopFeishuMonitor,
} from "./monitor.js";
afterEach(() => {
afterEach(async () => {
clearFeishuWebhookRateLimitStateForTest();
stopFeishuMonitor();
await stopFeishuMonitor();
});
describe("Feishu webhook security hardening", () => {