Skip to content

Commit 40f22f2

Browse files
authored
fix(devtools): handle transient RPC failures in getOptions/telemetryEvent (#1072)
1 parent 900d181 commit 40f22f2

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

‎packages/devtools/client/composables/storage-options.ts‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,23 @@ function getTabOptions<T extends keyof NuxtDevToolsOptions>(tab: T): ToRefs<Nuxt
2222
watchDebounced(
2323
source,
2424
async (options) => {
25-
rpc.updateOptions(tab, options)
25+
// Best-effort persistence: a transient RPC failure here (e.g. the
26+
// connection was torn down and re-established after a dev-server
27+
// reload) shouldn't surface as an uncaught error — the next change
28+
// will simply retry the write.
29+
rpc.updateOptions(tab, options).catch((error) => {
30+
console.error(`[nuxt-devtools] Failed to persist "${String(tab)}" options`, error)
31+
})
2632
},
2733
{ deep: true, flush: 'post', debounce: 500, maxWait: 1000 },
2834
)
2935
})
36+
.catch((error) => {
37+
// Same as above: don't let a transient disconnect (e.g. right after a
38+
// Nuxt dev-server reload) throw an uncaught error — fall back to the
39+
// in-memory defaults already seeded above and keep the UI usable.
40+
console.error(`[nuxt-devtools] Failed to load "${String(tab)}" options`, error)
41+
})
3042

3143
return refs
3244
}

‎packages/devtools/client/composables/telemetry.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,10 @@ export function telemetry(event: string, payload?: object, immediate = false) {
1616
osVersion: userAgentInfo.os.version,
1717
deviceType: userAgentInfo.device.type,
1818
...payload,
19-
}, immediate)
19+
}, immediate).catch((error) => {
20+
// Telemetry is best-effort: a transient RPC failure (e.g. the connection
21+
// was torn down and re-established after a dev-server reload) should
22+
// never surface to the user as an uncaught error.
23+
console.error('[nuxt-devtools] Failed to send telemetry event', error)
24+
})
2025
}

0 commit comments

Comments
 (0)