Merge f43072f9551196447ba08b15b803a03d0f4965d3 into 598f1826d8b2bc969aace2c6459824737667218c
This commit is contained in:
commit
87b8b72385
@ -44,8 +44,8 @@ async function waitForStartedAccount(started: string[], accountId: string) {
|
||||
}
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
stopFeishuMonitor();
|
||||
afterEach(async () => {
|
||||
await stopFeishuMonitor();
|
||||
});
|
||||
|
||||
describe("Feishu monitor startup preflight", () => {
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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", () => {
|
||||
|
||||
@ -35,9 +35,9 @@ import {
|
||||
stopFeishuMonitor,
|
||||
} from "./monitor.js";
|
||||
|
||||
afterEach(() => {
|
||||
afterEach(async () => {
|
||||
clearFeishuWebhookRateLimitStateForTest();
|
||||
stopFeishuMonitor();
|
||||
await stopFeishuMonitor();
|
||||
});
|
||||
|
||||
describe("Feishu webhook security hardening", () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user