chore(machines): verbose probe diagnostics
This commit is contained in:
parent
a1f456a5fd
commit
3417388cb0
1 changed files with 13 additions and 1 deletions
|
|
@ -29,15 +29,25 @@ export function AdminMachineDetailsClient({ tenantId: _tenantId, machineId }: {
|
|||
const [retryTick, setRetryTick] = useState(0)
|
||||
const shouldLoad = fallback === undefined && Boolean(machineId)
|
||||
|
||||
useEffect(() => {
|
||||
if (!shouldLoad) {
|
||||
console.debug("[admin-machine-details] Skipping probe", { shouldLoad, machineId, fallback, single })
|
||||
} else {
|
||||
console.debug("[admin-machine-details] Starting probe", { machineId, retryTick })
|
||||
}
|
||||
}, [shouldLoad, machineId, fallback, single, retryTick])
|
||||
|
||||
useEffect(() => {
|
||||
if (!shouldLoad) return
|
||||
let cancelled = false
|
||||
|
||||
const probe = async () => {
|
||||
console.debug("[admin-machine-details] Probe invocation", { machineId, retryTick })
|
||||
try {
|
||||
const convexUrl = process.env.NEXT_PUBLIC_CONVEX_URL
|
||||
if (convexUrl) {
|
||||
try {
|
||||
console.debug("[admin-machine-details] Convex probe begin", { machineId, convexUrl })
|
||||
const http = new ConvexHttpClient(convexUrl)
|
||||
const data = (await http.query(api.machines.getById, {
|
||||
id: machineId as Id<"machines">,
|
||||
|
|
@ -61,11 +71,12 @@ export function AdminMachineDetailsClient({ tenantId: _tenantId, machineId }: {
|
|||
}
|
||||
} catch (err) {
|
||||
if (cancelled) return
|
||||
console.warn("[admin-machine-details] Convex probe failed, falling back to API route", err)
|
||||
console.warn("[admin-machine-details] Convex probe failed, falling back to API route", { machineId, err })
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
console.debug("[admin-machine-details] HTTP fallback begin", { machineId })
|
||||
const res = await fetch(`/api/admin/machines/${machineId}/details`, {
|
||||
credentials: "include",
|
||||
cache: "no-store",
|
||||
|
|
@ -122,6 +133,7 @@ export function AdminMachineDetailsClient({ tenantId: _tenantId, machineId }: {
|
|||
})
|
||||
|
||||
return () => {
|
||||
console.debug("[admin-machine-details] Cancelling probe", { machineId })
|
||||
cancelled = true
|
||||
}
|
||||
}, [shouldLoad, machineId, retryTick])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue