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 [retryTick, setRetryTick] = useState(0)
|
||||||
const shouldLoad = fallback === undefined && Boolean(machineId)
|
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(() => {
|
useEffect(() => {
|
||||||
if (!shouldLoad) return
|
if (!shouldLoad) return
|
||||||
let cancelled = false
|
let cancelled = false
|
||||||
|
|
||||||
const probe = async () => {
|
const probe = async () => {
|
||||||
|
console.debug("[admin-machine-details] Probe invocation", { machineId, retryTick })
|
||||||
try {
|
try {
|
||||||
const convexUrl = process.env.NEXT_PUBLIC_CONVEX_URL
|
const convexUrl = process.env.NEXT_PUBLIC_CONVEX_URL
|
||||||
if (convexUrl) {
|
if (convexUrl) {
|
||||||
try {
|
try {
|
||||||
|
console.debug("[admin-machine-details] Convex probe begin", { machineId, convexUrl })
|
||||||
const http = new ConvexHttpClient(convexUrl)
|
const http = new ConvexHttpClient(convexUrl)
|
||||||
const data = (await http.query(api.machines.getById, {
|
const data = (await http.query(api.machines.getById, {
|
||||||
id: machineId as Id<"machines">,
|
id: machineId as Id<"machines">,
|
||||||
|
|
@ -61,11 +71,12 @@ export function AdminMachineDetailsClient({ tenantId: _tenantId, machineId }: {
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (cancelled) return
|
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 {
|
try {
|
||||||
|
console.debug("[admin-machine-details] HTTP fallback begin", { machineId })
|
||||||
const res = await fetch(`/api/admin/machines/${machineId}/details`, {
|
const res = await fetch(`/api/admin/machines/${machineId}/details`, {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
cache: "no-store",
|
cache: "no-store",
|
||||||
|
|
@ -122,6 +133,7 @@ export function AdminMachineDetailsClient({ tenantId: _tenantId, machineId }: {
|
||||||
})
|
})
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
console.debug("[admin-machine-details] Cancelling probe", { machineId })
|
||||||
cancelled = true
|
cancelled = true
|
||||||
}
|
}
|
||||||
}, [shouldLoad, machineId, retryTick])
|
}, [shouldLoad, machineId, retryTick])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue