Skip to content

Commit 10296f6

Browse files
committed
fix: fallback ttl not being passed
1 parent c76ec63 commit 10296f6

2 files changed

Lines changed: 38 additions & 4 deletions

File tree

packages/shared/sdk-client/__tests__/datasource/fdv2/FDv2SourceResult.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,30 @@ it('creates a goodbye status result', () => {
9595
});
9696
});
9797

98+
it('creates a goodbye status result with fdv1Fallback and a TTL', () => {
99+
const result = goodbye('server-shutdown', true, 5000);
100+
101+
expect(result).toEqual({
102+
type: 'status',
103+
state: 'goodbye',
104+
reason: 'server-shutdown',
105+
fdv1Fallback: true,
106+
fdv1FallbackTtlMs: 5000,
107+
});
108+
});
109+
110+
it('creates a goodbye status result with TTL 0 (indefinite fallback)', () => {
111+
const result = goodbye('server-shutdown', true, 0);
112+
113+
expect(result).toEqual({
114+
type: 'status',
115+
state: 'goodbye',
116+
reason: 'server-shutdown',
117+
fdv1Fallback: true,
118+
fdv1FallbackTtlMs: 0,
119+
});
120+
});
121+
98122
it('creates error info from an HTTP status code', () => {
99123
const info = errorInfoFromHttpError(503);
100124

packages/shared/sdk-client/src/datasource/fdv2/FDv2SourceResult.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,21 @@ export function terminalError(
101101
}
102102

103103
/**
104-
* Signals a server-initiated disconnect. Unlike terminal_error, this is
105-
* expected and the synchronizer handles reconnection internally.
104+
* Signals a server-initiated disconnect. Unlike `terminal_error`, the
105+
* synchronizer will reconnect; the orchestrator does not block this source.
106+
*
107+
* @param reason Human-readable description of why the server closed the stream.
108+
* @param fdv1Fallback Whether the server directed the client to fall back to FDv1.
109+
* @param fdv1FallbackTtlMs How long (ms) to remain on FDv1 before attempting FDv2
110+
* recovery. Omit to use the caller's default; pass `0` for indefinite fallback.
111+
* Same semantics as {@link StatusResult.fdv1FallbackTtlMs}.
106112
*/
107-
export function goodbye(reason: string, fdv1Fallback: boolean): FDv2SourceResult {
108-
return { type: 'status', state: 'goodbye', reason, fdv1Fallback };
113+
export function goodbye(
114+
reason: string,
115+
fdv1Fallback: boolean,
116+
fdv1FallbackTtlMs?: number,
117+
): FDv2SourceResult {
118+
return { type: 'status', state: 'goodbye', reason, fdv1Fallback, fdv1FallbackTtlMs };
109119
}
110120

111121
/** Builds {@link DataSourceStatusErrorInfo} for an unexpected HTTP status. */

0 commit comments

Comments
 (0)