Skip to content

Commit 28677fc

Browse files
fix: correctly test error is retriable
1 parent 9b5f03b commit 28677fc

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.7.0",
2+
"version": "0.8.0",
33
"name": "@meshcloud/notion-markdown-cms",
44
"engines": {
55
"node": ">=14"

src/NotionApiFacade.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ export class NotionApiFacade {
2626
}
2727

2828
async retrieveDatabase(databaseId: string) {
29-
return await this.withRetry(async () =>
30-
this.client.databases.retrieve({
29+
return await this.withRetry(async () => {
30+
return this.client.databases.retrieve({
3131
database_id: databaseId,
32-
})
33-
);
32+
});
33+
});
3434
}
3535

3636
async queryDatabase(query: DatabasesQueryParameters) {
@@ -82,7 +82,7 @@ export class NotionApiFacade {
8282
APIErrorCode.RateLimited,
8383
],
8484
retriableUnknownHTTPStatusCodes: number[] = [502]
85-
) {
85+
): Promise<T> {
8686
let lastError: any;
8787

8888
for (let i = 1; i <= maxRetries; i++) {
@@ -99,8 +99,9 @@ export class NotionApiFacade {
9999
RequestTimeoutError.isRequestTimeoutError(error) && error;
100100

101101
const isRetriable =
102-
(apiError && error.code in retriableApiErrorCodes) ||
103-
(unknownError && error.status in retriableUnknownHTTPStatusCodes) ||
102+
(apiError && retriableApiErrorCodes.includes(error.code)) ||
103+
(unknownError &&
104+
retriableUnknownHTTPStatusCodes.includes(error.status)) ||
104105
timeoutError;
105106

106107
if (!isRetriable) {

0 commit comments

Comments
 (0)