fix(hwlab-node): log cloud diagnostics

This commit is contained in:
lyon
2026-06-25 11:02:52 +08:00
parent 796de839c5
commit c8a76f33ac
+2
View File
@@ -24,6 +24,7 @@ type PendingDispatch = {
export function createHwpodNodeWsRegistry(options: any = {}) {
const now = options.now ?? (() => new Date().toISOString());
const clock = options.clock ?? (() => Date.now());
const logger = options.logger ?? console;
const connections = new Map<string, HwpodNodeConnection>();
const pending = new Map<string, PendingDispatch>();
const socketConnections = new WeakMap<object, HwpodNodeConnection>();
@@ -145,6 +146,7 @@ export function createHwpodNodeWsRegistry(options: any = {}) {
const diagnostic = normalizeDiagnostic(message.diagnostic, now());
connection.diagnostics.push(diagnostic);
if (connection.diagnostics.length > 50) connection.diagnostics = connection.diagnostics.slice(-50);
logger.warn?.(JSON.stringify({ event: "hwpod-node.diagnostic", nodeId: connection.nodeId || nodeId || null, connectionId: connection.id, diagnostic, valuesPrinted: false }));
sendJson(connection, { type: "ack", requestId: safeText(message.requestId) || "diagnostic", ok: true, message: "diagnostic recorded" });
return;
}