-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
(Potentially related to actions/github-script#229, but I don't think it's a duplicate)
Describe the bug
I am facing GitHub rate limiting issues so I want to throttle my requests. However, when I add @octokit/plugin-throttling to the call of github.getOctokit, I am getting a TypeScript compile error I cannot get rid of.
To Reproduce
(Note: you can see this issue affecting following PR: aws-actions/stale-issue-cleanup#392)
Steps to reproduce the behavior:
1. Pre-reqs
This is my package.json:
{
"name": "stale-issue-cleanup",
"version": "7.1.0",
"description": "GitHub Action that cleans up old and response-reqested issues",
"private": true,
"main": "src/entrypoint.ts",
"scripts": {
"check-lint": "prettier --list-different src/**.js && eslint src/**.js",
"lint": "biome check --write src",
"test": "npm run lint && vitest run && npm run build",
"build": "tsc",
"package": "npm run build && ncc build -s -m --license THIRD-PARTY -o dist && node -e \"require('fs').cpSync('dist/THIRD-PARTY', './THIRD-PARTY')\"",
"coverage": "vitest run --coverage"
},
"engines": {
"node": ">=18"
},
"repository": {
"type": "git",
"url": "git+https://github.com/aws-actions/stale-issue-cleanup"
},
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/aws-actions/stale-issue-cleanup/issues"
},
"homepage": "https://github.com/aws-actions/stale-issue-cleanup/#readme",
"dependencies": {
"@actions/core": "^1.11.1",
"@actions/github": "^6.0.1",
"@octokit/core": "^7.0.6",
"@octokit/plugin-throttling": "^11.0.3",
"dateformat": "^4.4.1"
},
"devDependencies": {
"@biomejs/biome": "2.1.2",
"@fetch-mock/vitest": "^0.2.14",
"@octokit/plugin-rest-endpoint-methods": "^13.3.0",
"@types/dateformat": "^5.0.3",
"@types/node": "^24.1.0",
"@vercel/ncc": "^0.38.3",
"@vitest/coverage-v8": "^2.1.8",
"dotenv": "^17.2.1",
"typescript": "^5.8.3",
"vitest": "^2.1.8"
}
}This is my tsconfig.json:
{
"compilerOptions": {
"target": "ES2022",
"module": "commonjs",
"declaration": true,
"outDir": "dist",
"declarationDir": "dist/types",
"sourceMap": true,
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"noImplicitThis": true,
"alwaysStrict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"experimentalDecorators": true,
"strictPropertyInitialization": true,
"esModuleInterop": true,
},
"exclude": ["node_modules", "dist", "test", "vitest.config.ts"]
}
2. This is the code I am trying to write
import * as github from '@actions/github';
// ...
const client = github.getOctokit(args.repoToken, {
request: { fetch: fetchImpl || globalThis.fetch },
throttle: {
onRateLimit: (retryAfter: number, options: EndpointDefaults, octokit: Octokit, retryCount: number) => {
octokit.log.warn(
`Request quota exhausted for request ${options.method} ${options.url}. Retrying after ${retryAfter} seconds!`,
);
if (retryCount < 3) {
// only retries 3 times
octokit.log.info(`Retrying after ${retryAfter} seconds! ${retryCount} times`);
return true;
}
return undefined;
},
onSecondaryRateLimit: (retryAfter: number, options: EndpointDefaults, octokit: Octokit) => {
// does not retry, only logs a warning
octokit.log.warn(
`SecondaryRateLimit detected for request ${options.method} ${options.url}. Retrying after ${retryAfter} seconds!`,
);
return undefined;
},
},
}, throttling);
...3. Error
This is the type error I'm getting on the last line of the snippet above:
Argument of type 'typeof throttling' is not assignable to parameter of type 'OctokitPlugin'.
Types of parameters 'octokit' and 'octokit' are incompatible.
Type 'import("/workspace/stale-issue-cleanup/node_modules/@actions/github/node_modules/@octokit/core/dist-types/index").Octokit' is not assignable to type 'import("/workspace/stale-issue-cleanup/node_modules/@octokit/core/dist-types/index").Octokit'.
The types returned by 'request.defaults(...)(...)' are incompatible between these types.
Type 'Promise<import("/workspace/stale-issue-cleanup/node_modules/@octokit/types/dist-types/OctokitResponse").OctokitResponse<any, number>>' is not assignable to type 'Promise<import("/workspace/stale-issue-cleanup/node_modules/@octokit/request/node_modules/@octokit/types/dist-types/OctokitResponse").OctokitResponse<any, number>>'.
Property 'retryCount' is missing in type 'import("/workspace/stale-issue-cleanup/node_modules/@octokit/types/dist-types/OctokitResponse").OctokitResponse<any, number>' but required in type 'import("/workspace/stale-issue-cleanup/node_modules/@octokit/request/node_modules/@octokit/types/dist-types/OctokitResponse").OctokitResponse<any, number>'.ts(2345)
index.d.ts(15, 9): 'retryCount' is declared here.
Expected behavior
No TypeScript errors are reported and project compiles fine.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working