Skip to content

Commit

Permalink
Better request retry system
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu2301 committed Jul 20, 2023
1 parent 65c1564 commit ac66561
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/notion/DatabaseController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ export default class DatabaseController {
constructor({ auth, dbIDs }: DatabaseControllerConfig) {
this.client = new Client({
auth,
fetch: async (url: string, init?: RequestInit) => {
async fetch(url: string, init?: RequestInit) {
try {
const res = await fetch(url, init);
if (!res.ok) throw new Error();
return res;
} catch (err) {
console.warn('Notion API error, retrying...');
} catch {
console.warn(`\nNotion API error (${url}), retrying...\n`);
await new Promise((resolve) => setTimeout(resolve, 1000));
return fetch(url, init);
}
Expand Down

0 comments on commit ac66561

Please sign in to comment.