Files
orca/src/shared/mobile-relay-close-codes.test.ts
T
Jinwoo HongandClaude 9ea5434371 fix(mobile): faster relay recovery after an app switch and on a late desktop data link (#30607)
* fix(mobile): recover a relay that died during an app switch in one short probe, and retry an attach timeout through the director once

Refs STA-11130.

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(mobile): redial the same cell once on attach-timeout instead of re-resolving

Aligns with the relay step 6 design: reason string attach-timeout, no director
re-resolve (the director names the cell the host is seated on).

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(mobile): probe decisively only on a real background return, 4s, and jitter the attach-timeout redial

Co-Authored-By: Claude <noreply@anthropic.com>

* test(mobile): replace type assertions with a typed fake in the relay probe tests

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-19 03:30:06 -04:00

58 lines
1.7 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import {
isMobileRelayCloseCode,
MOBILE_RELAY_CLOSE_CODE,
MOBILE_RELAY_PHONE_CLOSE_REASON,
mobileRelayRecoveryFor
} from './mobile-relay-close-codes'
describe('mobile relay close-code contract', () => {
it('locks all application close codes', () => {
expect(MOBILE_RELAY_CLOSE_CODE).toEqual({
BAD_OUTER_CREDENTIAL: 4401,
HOST_OFFLINE: 4404,
PEER_DROPPED: 4408,
WRONG_CELL: 4409,
LIMIT_EXCEEDED: 4429,
DRAINING: 4503
})
expect(isMobileRelayCloseCode(4409)).toBe(true)
expect(isMobileRelayCloseCode(1006)).toBe(false)
})
it('locks the phone close reasons the relay mirrors', () => {
expect(MOBILE_RELAY_PHONE_CLOSE_REASON).toEqual({ HOST_ATTACH_TIMEOUT: 'attach-timeout' })
})
it('uses the configured director and never a cell-supplied URL', () => {
expect(mobileRelayRecoveryFor(4503, 'host-control')).toEqual({
kind: 'resolve-configured-director',
fullJitter: true
})
})
it('separates invite and resume wrong-cell recovery', () => {
expect(mobileRelayRecoveryFor(4409, 'phone-invite')).toEqual({
kind: 'resolve-invite-through-director-ws',
requireStrictlyNewerEpoch: true
})
expect(mobileRelayRecoveryFor(4409, 'phone-resume')).toEqual({
kind: 'resolve-resume-through-director-post'
})
})
it('keeps outer credential failure endpoint-scoped', () => {
expect(mobileRelayRecoveryFor(4401, 'phone-resume')).toEqual({
kind: 'disable-relay-credential',
directUnaffected: true
})
})
it('keeps host-offline recovery self-healing', () => {
expect(mobileRelayRecoveryFor(4404, 'phone-resume')).toEqual({
kind: 'retry-after-host-offline',
fullJitter: true
})
})
})