Skip to content

Commit 8158b5e

Browse files
authored
fix: log removeDevice failures with structured error fields
Apply reviewer feedback from PR #1283 review: - Log err.name and err.message instead of raw err object to avoid {} serialization in JSON-based loggers, consistent with teardown() and connect() error handling patterns in the same file - Reformat long chained call in connect() for readability
1 parent b929ed4 commit 8158b5e

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

apps/web/src/pages/Connections/useConnections.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,15 @@ export function useConnections() {
8888
if (conn?.meshDeviceId) {
8989
try {
9090
useDeviceStore.getState().removeDevice(conn.meshDeviceId);
91-
} catch {}
91+
} catch (e) {
92+
const err = e as Error;
93+
log.warn("removeDevice failed during removeConnection", {
94+
id,
95+
meshDeviceId: conn.meshDeviceId,
96+
name: err?.name,
97+
message: err?.message,
98+
});
99+
}
92100
}
93101
meshRegistry.unregister(id);
94102
removeSavedConnectionFromStore(id);
@@ -249,7 +257,9 @@ export function useConnections() {
249257
// Read from the live store, not the memoized `connections` closure: callers
250258
// such as addConnectionAndConnect() add a connection and connect to it in the
251259
// same tick, before this hook re-renders, so the closure would be stale.
252-
const conn = useDeviceStore.getState().savedConnections.find((c) => c.id === id);
260+
const conn = useDeviceStore
261+
.getState()
262+
.savedConnections.find((c) => c.id === id);
253263
if (!conn) {
254264
log.warn("connect: unknown connection id", { id });
255265
return false;

0 commit comments

Comments
 (0)