Skip to content

chore(#47/#48): retry classification, missing failover tests, type-check tests#65

Merged
arniesaha merged 1 commit intomasterfrom
chore/issue-47-48
May 6, 2026
Merged

chore(#47/#48): retry classification, missing failover tests, type-check tests#65
arniesaha merged 1 commit intomasterfrom
chore/issue-47-48

Conversation

@arniesaha
Copy link
Copy Markdown
Owner

Summary

Closes #47 and #48 in one PR (both touch the same testing/observability surface area introduced by #45/#46).

#47 — failover follow-ups

  • Retry classification: isRetryableDownstreamError now consults err.cause.code authoritatively (undici wraps the real network error there) for ECONNREFUSED, ECONNRESET, ENOTFOUND, EAI_AGAIN, ETIMEDOUT, EPIPE, and UND_ERR_*. The "fetch failed" message-substring check is kept as a fallback so we don't regress current behavior if Node ever stops attaching cause.
  • Three new tests:
    • parameterized cause.code classification (6 codes + AbortError + plain non-network error)
    • 3-provider chain-order: a → b → c, primary and first fallback error, third succeeds, asserts call order
    • streaming headers-sent guard with a retryable mid-stream error: provider A streams a frame (flips headersSent), then errors with ECONNRESET; dispatcher must not failover (would corrupt SSE), provider B is never called
  • Enriched mux.failover_hop log: now includes fromUrl/toUrl (looked up from config.providers) and a reason field that surfaces cause.code on network errors (e.g. TypeError:ECONNRESET)

#48 — type-check tests

  • tsconfig.test.json extends the base config with tests/**/*.ts included
  • npm run check now runs tsc --noEmit against both tsconfig.json and tsconfig.test.json
  • Fixed the drift this surfaced: shared route fixture in tests/downstream.test.ts was missing providerId/fallbackProviderIds, and provider mocks in tests/policy.test.ts were missing protocols

Deferred from #47

Item 3 (rename prov.route.provider_idprov.effective.provider_id to keep the original route decision immutable) intentionally NOT in this PR — needs coordination with the AgentWeave Routing tab (arniesaha/agentweave#164) before flipping the schema.

Testing

  • npm test → 118/118 (was 107)
  • npm run check → clean (src + tests)

…check tests

#47 follow-ups:
- Make err.cause.code authoritative in isRetryableDownstreamError; keep "fetch failed" message-substring as a fallback. Adds explicit ECONNREFUSED/ECONNRESET/ENOTFOUND/EAI_AGAIN/ETIMEDOUT/EPIPE/UND_ERR_* coverage so the dispatcher does not depend on Node's exact error wording.
- Tests: parameterized cause.code retryability, three-provider chain-order (a→b→c success on c), streaming headers-sent guard with a retryable mid-stream error (must NOT failover after bytes are sent — would corrupt SSE framing).
- Enrich mux.failover_hop log: include from/to provider URLs and a richer reason field that surfaces cause.code on network errors.

#48:
- Add tsconfig.test.json that includes tests/**/*.ts; wire npm run check to run both. Surfaces existing fixture drift (RouteDecision missing providerId/fallbackProviderIds; Provider mocks missing protocols) — fixed in the same commit.

Closes #47, #48

Note: prov.route.provider_id immutability + prov.effective.provider_id rename
(item 3 in #47) intentionally deferred — needs coordination with the
AgentWeave Routing tab (arniesaha/agentweave#164).
@arniesaha arniesaha merged commit 76aabdb into master May 6, 2026
1 check passed
@arniesaha arniesaha deleted the chore/issue-47-48 branch May 6, 2026 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore(mux #45 follow-ups): retryability, tests, span naming

1 participant