Skip to content

Commit 03bfd82

Browse files
committed
fix rc
1 parent 9b1ed6c commit 03bfd82

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

packages/remote-config/src/client/retrying_client.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,17 @@ export function setAbortableTimeout(
6161
});
6262
}
6363

64+
type RetriableError = FirebaseError & { customData: { httpStatus: string } };
6465
/**
6566
* Returns true if the {@link Error} indicates a fetch request may succeed later.
6667
*/
67-
function isRetriableError(e: Error): boolean {
68-
if (!(e instanceof FirebaseError)) {
68+
function isRetriableError(e: Error): e is RetriableError {
69+
if (!(e instanceof FirebaseError) || !e.customData) {
6970
return false;
7071
}
7172

7273
// Uses string index defined by ErrorData, which FirebaseError implements.
73-
const httpStatus = Number(e['httpStatus']);
74+
const httpStatus = Number(e.customData['httpStatus']);
7475

7576
return (
7677
httpStatus === 429 ||

packages/remote-config/test/client/rest_client.test.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ describe('RestClient', () => {
134134

135135
await expect(fetchPromise)
136136
.to.eventually.be.rejectedWith(FirebaseError, firebaseError.message)
137-
.with.property('originalErrorMessage', 'Network request failed');
137+
.with.nested.property(
138+
'customData.originalErrorMessage',
139+
'Network request failed'
140+
);
138141
});
139142

140143
it('throws on JSON parse failure', async () => {
@@ -154,7 +157,10 @@ describe('RestClient', () => {
154157

155158
await expect(fetchPromise)
156159
.to.eventually.be.rejectedWith(FirebaseError, firebaseError.message)
157-
.with.property('originalErrorMessage', 'Unexpected end of input');
160+
.with.nested.property(
161+
'customData.originalErrorMessage',
162+
'Unexpected end of input'
163+
);
158164
});
159165

160166
it('handles 304 status code and empty body', async () => {
@@ -200,7 +206,7 @@ describe('RestClient', () => {
200206

201207
await expect(fetchPromise)
202208
.to.eventually.be.rejectedWith(FirebaseError, error.message)
203-
.with.property('httpStatus', 500);
209+
.with.nested.property('customData.httpStatus', 500);
204210
});
205211

206212
it('normalizes NO_CHANGE state to 304 status', async () => {
@@ -257,7 +263,7 @@ describe('RestClient', () => {
257263

258264
await expect(fetchPromise)
259265
.to.eventually.be.rejectedWith(FirebaseError, error.message)
260-
.with.property('httpStatus', status);
266+
.with.nested.property('customData.httpStatus', status);
261267
}
262268
});
263269
});

0 commit comments

Comments
 (0)