Files
orca/src/main/ipc/runtime-environments/runtime-environment-control-socket-close-trace.test.ts
T
Neil b33ad1bb2c feat(remote): trace why each remote-runtime connection closed (#33094)
Client control-socket closes and server heartbeat reaps only reached the
console, which a packaged app never shows. Each control-socket close now
writes a remote-runtime.control-socket-close span (cause, close code,
error code, last keepalive RTT, socket and ready uptime). Each server reap
writes remote-runtime.server-socket-reaped. Both land in the main trace
file that Send app diagnostics collects. Keepalive pongs now measure RTT,
exposed as lastRttMs and lastCloseCause on the shared-control diagnostics.
2026-10-24 01:43:08 -07:00

37 lines
1.1 KiB
TypeScript

import { afterEach, expect, it } from 'vitest'
import { setActiveSink } from '../../observability/tracer'
import { sharedControlEnvironmentPolicy } from './runtime-environment-shared-control-policy'
afterEach(() => setActiveSink(null))
it('traces each control socket close for the support bundle', () => {
const records: unknown[] = []
setActiveSink({ push: (record) => records.push(record), flush() {}, close() {} })
sharedControlEnvironmentPolicy('env-1').onSocketClosed?.({
cause: 'keepalive_timeout',
errorCode: 'remote_runtime_unavailable',
closeCode: null,
state: 'ready',
lastRttMs: 320,
socketUptimeMs: 60_000,
readyUptimeMs: 59_000,
reconnectAttempt: 0,
pendingRequestCount: 1,
subscriptionCount: 4
})
expect(records).toEqual([
expect.objectContaining({
type: 'effect-span',
name: 'remote-runtime.control-socket-close',
attributes: expect.objectContaining({
environmentId: 'env-1',
cause: 'keepalive_timeout',
lastRttMs: 320,
socketUptimeMs: 60_000
})
})
])
})