Skip to content

Commit cf9c716

Browse files
fix(discord): surface gateway overflow warnings
Co-authored-by: 张贵萍0668001030 <[email protected]>
1 parent 91d2cfc commit cf9c716

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

extensions/discord/src/gateway-logging.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
44

55
vi.mock("openclaw/plugin-sdk/runtime-env", () => ({
66
logVerbose: vi.fn(),
7+
warn: (message: string) => `warn:${message}`,
78
}));
89

910
let logVerbose: typeof import("openclaw/plugin-sdk/runtime-env").logVerbose;
@@ -58,7 +59,7 @@ describe("attachDiscordGatewayLogging", () => {
5859
cleanup();
5960
});
6061

61-
it("logs warnings and metrics only to verbose", () => {
62+
it("promotes warnings while keeping metrics verbose-only", () => {
6263
const emitter = new EventEmitter();
6364
const runtime = makeRuntime();
6465

@@ -72,7 +73,9 @@ describe("attachDiscordGatewayLogging", () => {
7273

7374
const logVerboseMock = vi.mocked(logVerbose);
7475
expect(logVerboseMock).toHaveBeenCalledTimes(2);
75-
expect(runtime.log).not.toHaveBeenCalled();
76+
expect(runtime.log).toHaveBeenCalledWith(
77+
"warn:discord gateway warning: High latency detected: 1200ms",
78+
);
7679

7780
cleanup();
7881
});

extensions/discord/src/gateway-logging.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Discord plugin module implements gateway logging behavior.
22
import type { EventEmitter } from "node:events";
3-
import { logVerbose } from "openclaw/plugin-sdk/runtime-env";
3+
import { logVerbose, warn } from "openclaw/plugin-sdk/runtime-env";
44
import type { RuntimeEnv } from "openclaw/plugin-sdk/runtime-env";
55

66
type GatewayEmitter = Pick<EventEmitter, "on" | "removeListener">;
@@ -49,7 +49,9 @@ export function attachDiscordGatewayLogging(params: {
4949
};
5050

5151
const onGatewayWarning = (warning: unknown) => {
52-
logVerbose(`discord gateway warning: ${String(warning)}`);
52+
const message = `discord gateway warning: ${String(warning)}`;
53+
logVerbose(message);
54+
runtime.log?.(warn(message));
5355
};
5456

5557
const onGatewayMetrics = (metrics: unknown) => {

0 commit comments

Comments
 (0)