chore(discord): restore gateway log context

This commit is contained in:
Peter Steinberger
2026-01-13 04:35:52 +00:00
parent ccc24e2c26
commit 7c7f4d0eb7
3 changed files with 8 additions and 8 deletions

View File

@@ -36,11 +36,11 @@ describe("attachDiscordGatewayLogging", () => {
expect(runtime.log).toHaveBeenCalledTimes(2); expect(runtime.log).toHaveBeenCalledTimes(2);
expect(runtime.log).toHaveBeenNthCalledWith( expect(runtime.log).toHaveBeenNthCalledWith(
1, 1,
"gateway: WebSocket connection closed with code 1001", "discord gateway: WebSocket connection closed with code 1001",
); );
expect(runtime.log).toHaveBeenNthCalledWith( expect(runtime.log).toHaveBeenNthCalledWith(
2, 2,
"gateway: Reconnecting with backoff: 1000ms after code 1001", "discord gateway: Reconnecting with backoff: 1000ms after code 1001",
); );
cleanup(); cleanup();

View File

@@ -40,18 +40,18 @@ export function attachDiscordGatewayLogging(params: {
const onGatewayDebug = (msg: unknown) => { const onGatewayDebug = (msg: unknown) => {
const message = String(msg); const message = String(msg);
logVerbose(`gateway: ${message}`); logVerbose(`discord gateway: ${message}`);
if (shouldPromoteGatewayDebug(message)) { if (shouldPromoteGatewayDebug(message)) {
runtime.log?.(`gateway: ${message}`); runtime.log?.(`discord gateway: ${message}`);
} }
}; };
const onGatewayWarning = (warning: unknown) => { const onGatewayWarning = (warning: unknown) => {
logVerbose(`gateway warning: ${String(warning)}`); logVerbose(`discord gateway warning: ${String(warning)}`);
}; };
const onGatewayMetrics = (metrics: unknown) => { const onGatewayMetrics = (metrics: unknown) => {
logVerbose(`gateway metrics: ${formatGatewayMetrics(metrics)}`); logVerbose(`discord gateway metrics: ${formatGatewayMetrics(metrics)}`);
}; };
emitter.on("debug", onGatewayDebug); emitter.on("debug", onGatewayDebug);

View File

@@ -661,7 +661,7 @@ export async function monitorDiscordProvider(opts: MonitorDiscordOpts = {}) {
if (!gateway?.isConnected) { if (!gateway?.isConnected) {
runtime.log?.( runtime.log?.(
danger( danger(
`[discord] connection stalled: no HELLO received within ${HELLO_TIMEOUT_MS}ms, forcing reconnect`, `connection stalled: no HELLO received within ${HELLO_TIMEOUT_MS}ms, forcing reconnect`,
), ),
); );
gateway?.disconnect(); gateway?.disconnect();
@@ -681,7 +681,7 @@ export async function monitorDiscordProvider(opts: MonitorDiscordOpts = {}) {
: undefined, : undefined,
abortSignal: opts.abortSignal, abortSignal: opts.abortSignal,
onGatewayError: (err) => { onGatewayError: (err) => {
runtime.error?.(danger(`gateway error: ${String(err)}`)); runtime.error?.(danger(`discord gateway error: ${String(err)}`));
}, },
shouldStopOnError: (err) => { shouldStopOnError: (err) => {
const message = String(err); const message = String(err);