Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -742,14 +742,21 @@ class IssuesProcessor {
});
}
getRateLimit() {
var _a;
return __awaiter(this, void 0, void 0, function* () {
const logger = new logger_1.Logger();
try {
const rateLimitResult = yield this.client.rest.rateLimit.get();
return new rate_limit_1.RateLimit(rateLimitResult.data.rate);
}
catch (error) {
logger.error(`Error when getting rateLimit: ${error.message}`);
const status = error === null || error === void 0 ? void 0 : error.status;
const message = (_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : String(error);
if (status === 404 && message.includes('Rate limiting is not enabled')) {
logger.warning('Rate limiting is not enabled on this instance. Proceeding without rate limit checks.');
return undefined;
}
logger.error(`Error when getting rateLimit: ${message}`);
}
});
}
Expand Down
15 changes: 13 additions & 2 deletions src/classes/issues-processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -643,11 +643,22 @@ export class IssuesProcessor {

async getRateLimit(): Promise<IRateLimit | undefined> {
const logger: Logger = new Logger();

try {
const rateLimitResult = await this.client.rest.rateLimit.get();
return new RateLimit(rateLimitResult.data.rate);
} catch (error) {
logger.error(`Error when getting rateLimit: ${error.message}`);
} catch (error: unknown) {
const status = (error as {status?: number})?.status;
const message = (error as {message?: string})?.message ?? String(error);

if (status === 404 && message.includes('Rate limiting is not enabled')) {
logger.warning(
'Rate limiting is not enabled on this instance. Proceeding without rate limit checks.'
);
return undefined;
}

logger.error(`Error when getting rateLimit: ${message}`);
}
}

Expand Down
Loading