Skip to content

Commit 3b764af

Browse files
author
Louis Béranger
committed
fix: Addresses #341 (gracefully ignore bad rate limit data in paginators)
1 parent d9eddf3 commit 3b764af

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/paginators/TwitterPaginator.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ export abstract class TwitterPaginator<TApiResult, TApiParams extends object, TI
3232
}
3333

3434
protected get _isRateLimitOk() {
35+
if (!this._rateLimit) {
36+
return true;
37+
}
38+
3539
const resetDate = this._rateLimit.reset * 1000;
3640

3741
if (resetDate < Date.now()) {
@@ -137,7 +141,7 @@ export abstract class TwitterPaginator<TApiResult, TApiParams extends object, TI
137141
}
138142

139143
get rateLimit() {
140-
return { ...this._rateLimit };
144+
return { ...this._rateLimit ?? {} };
141145
}
142146

143147
/** Get raw data returned by Twitter API. */

0 commit comments

Comments
 (0)