Merge pull request #2112 from pikasTech/fix/2097-cloud-diagnostic-log
fix(hwlab-node): log cloud diagnostics
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user