Skip to content

Commit 6b03226

Browse files
abueideclaude
andcommitted
fix: remove retryStrategy from Config, add SDD error tests
- Remove retryStrategy config option from Config type (hardcoded to eager in RetryManager downstream) - Add 14 SDD-default config tests verifying all spec status codes (408/410/460=retry, 501/505=drop, 429=rate_limit, etc.) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a3ac0e5 commit 6b03226

2 files changed

Lines changed: 100 additions & 6 deletions

File tree

packages/core/src/__tests__/errors-classification.test.ts

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,106 @@
11
import { classifyError, parseRetryAfter } from '../errors';
22

33
describe('classifyError', () => {
4+
describe('SDD-default config (statusCodeOverrides per spec)', () => {
5+
const sddConfig = {
6+
default4xxBehavior: 'drop' as const,
7+
default5xxBehavior: 'retry' as const,
8+
statusCodeOverrides: {
9+
'408': 'retry' as const,
10+
'410': 'retry' as const,
11+
'429': 'retry' as const,
12+
'460': 'retry' as const,
13+
'501': 'drop' as const,
14+
'505': 'drop' as const,
15+
},
16+
rateLimitEnabled: true,
17+
};
18+
19+
it('retries 408 (Request Timeout)', () => {
20+
const result = classifyError(408, sddConfig);
21+
expect(result.isRetryable).toBe(true);
22+
expect(result.errorType).toBe('transient');
23+
});
24+
25+
it('retries 410 (Gone)', () => {
26+
const result = classifyError(410, sddConfig);
27+
expect(result.isRetryable).toBe(true);
28+
expect(result.errorType).toBe('transient');
29+
});
30+
31+
it('retries 460 (Client timeout)', () => {
32+
const result = classifyError(460, sddConfig);
33+
expect(result.isRetryable).toBe(true);
34+
expect(result.errorType).toBe('transient');
35+
});
36+
37+
it('rate-limits 429 (Too Many Requests)', () => {
38+
const result = classifyError(429, sddConfig);
39+
expect(result.isRetryable).toBe(true);
40+
expect(result.errorType).toBe('rate_limit');
41+
});
42+
43+
it('drops 400 (Bad Request)', () => {
44+
const result = classifyError(400, sddConfig);
45+
expect(result.isRetryable).toBe(false);
46+
expect(result.errorType).toBe('permanent');
47+
});
48+
49+
it('drops 401 (Unauthorized)', () => {
50+
const result = classifyError(401, sddConfig);
51+
expect(result.isRetryable).toBe(false);
52+
expect(result.errorType).toBe('permanent');
53+
});
54+
55+
it('drops 413 (Payload Too Large)', () => {
56+
const result = classifyError(413, sddConfig);
57+
expect(result.isRetryable).toBe(false);
58+
expect(result.errorType).toBe('permanent');
59+
});
60+
61+
it('drops 501 (Not Implemented)', () => {
62+
const result = classifyError(501, sddConfig);
63+
expect(result.isRetryable).toBe(false);
64+
expect(result.errorType).toBe('permanent');
65+
});
66+
67+
it('drops 505 (HTTP Version Not Supported)', () => {
68+
const result = classifyError(505, sddConfig);
69+
expect(result.isRetryable).toBe(false);
70+
expect(result.errorType).toBe('permanent');
71+
});
72+
73+
it('retries 500 (Internal Server Error)', () => {
74+
const result = classifyError(500, sddConfig);
75+
expect(result.isRetryable).toBe(true);
76+
expect(result.errorType).toBe('transient');
77+
});
78+
79+
it('retries 502 (Bad Gateway)', () => {
80+
const result = classifyError(502, sddConfig);
81+
expect(result.isRetryable).toBe(true);
82+
expect(result.errorType).toBe('transient');
83+
});
84+
85+
it('retries 503 (Service Unavailable)', () => {
86+
const result = classifyError(503, sddConfig);
87+
expect(result.isRetryable).toBe(true);
88+
expect(result.errorType).toBe('transient');
89+
});
90+
91+
it('retries 504 (Gateway Timeout)', () => {
92+
const result = classifyError(504, sddConfig);
93+
expect(result.isRetryable).toBe(true);
94+
expect(result.errorType).toBe('transient');
95+
});
96+
97+
it('retries 508 (Loop Detected)', () => {
98+
const result = classifyError(508, sddConfig);
99+
expect(result.isRetryable).toBe(true);
100+
expect(result.errorType).toBe('transient');
101+
});
102+
});
103+
4104
describe('statusCodeOverrides precedence', () => {
5105
it('uses override for specific status code', () => {
6106
const config = {

packages/core/src/types.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,6 @@ export type Config = {
154154
cdnProxy?: string;
155155
useSegmentEndpoints?: boolean; // Use if you want to use Segment endpoints
156156
errorHandler?: (error: SegmentError) => void;
157-
/**
158-
* Controls how concurrent batch errors are consolidated into a single retry delay.
159-
* - 'lazy' (default): uses the longest wait time (most conservative, fewer retries)
160-
* - 'eager': uses the shortest wait time (more aggressive, retries sooner)
161-
*/
162-
retryStrategy?: 'eager' | 'lazy';
163157
};
164158

165159
export type ClientMethods = {

0 commit comments

Comments
 (0)