@@ -11676,77 +11676,61 @@ retry.VERSION = VERSION;
11676
11676
/***/ }),
11677
11677
11678
11678
/***/ 9968:
11679
- /***/ ((module, __unused_webpack_exports , __nccwpck_require__) => {
11679
+ /***/ ((__unused_webpack_module, exports , __nccwpck_require__) => {
11680
11680
11681
11681
11682
- var __create = Object.create;
11683
- var __defProp = Object.defineProperty;
11684
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
11685
- var __getOwnPropNames = Object.getOwnPropertyNames;
11686
- var __getProtoOf = Object.getPrototypeOf;
11687
- var __hasOwnProp = Object.prototype.hasOwnProperty;
11688
- var __export = (target, all) => {
11689
- for (var name in all)
11690
- __defProp(target, name, { get: all[name], enumerable: true });
11691
- };
11692
- var __copyProps = (to, from, except, desc) => {
11693
- if (from && typeof from === "object" || typeof from === "function") {
11694
- for (let key of __getOwnPropNames(from))
11695
- if (!__hasOwnProp.call(to, key) && key !== except)
11696
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11697
- }
11698
- return to;
11699
- };
11700
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
11701
- // If the importer is in node compatibility mode or this is not an ESM
11702
- // file that has been converted to a CommonJS file using a Babel-
11703
- // compatible transform (i.e. "__esModule" has not been set), then set
11704
- // "default" to the CommonJS "module.exports" for node compatibility.
11705
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
11706
- mod
11707
- ));
11708
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
11709
11682
11710
- // pkg/dist-src/index.js
11711
- var dist_src_exports = {};
11712
- __export(dist_src_exports, {
11713
- throttling: () => throttling
11714
- });
11715
- module.exports = __toCommonJS(dist_src_exports);
11716
- var import_light = __toESM(__nccwpck_require__(1174));
11683
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
11717
11684
11718
- // pkg/dist-src/version.js
11719
- var VERSION = "6.1.0";
11685
+ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
11720
11686
11721
- // pkg/dist-src/wrap-request.js
11722
- var noop = () => Promise.resolve();
11687
+ var BottleneckLight = _interopDefault(__nccwpck_require__(1174));
11688
+
11689
+ const VERSION = "5.2.3";
11690
+
11691
+ const noop = () => Promise.resolve();
11692
+ // @ts-expect-error
11723
11693
function wrapRequest(state, request, options) {
11724
11694
return state.retryLimiter.schedule(doRequest, state, request, options);
11725
11695
}
11696
+ // @ts-expect-error
11726
11697
async function doRequest(state, request, options) {
11727
11698
const isWrite = options.method !== "GET" && options.method !== "HEAD";
11728
- const { pathname } = new URL(options.url, "http://github.test");
11699
+ const {
11700
+ pathname
11701
+ } = new URL(options.url, "http://github.test");
11729
11702
const isSearch = options.method === "GET" && pathname.startsWith("/search/");
11730
11703
const isGraphQL = pathname.startsWith("/graphql");
11731
11704
const retryCount = ~~request.retryCount;
11732
- const jobOptions = retryCount > 0 ? { priority: 0, weight: 0 } : {};
11705
+ const jobOptions = retryCount > 0 ? {
11706
+ priority: 0,
11707
+ weight: 0
11708
+ } : {};
11733
11709
if (state.clustering) {
11734
- jobOptions.expiration = 1e3 * 60;
11710
+ // Remove a job from Redis if it has not completed or failed within 60s
11711
+ // Examples: Node process terminated, client disconnected, etc.
11712
+ // @ts-expect-error
11713
+ jobOptions.expiration = 1000 * 60;
11735
11714
}
11715
+ // Guarantee at least 1000ms between writes
11716
+ // GraphQL can also trigger writes
11736
11717
if (isWrite || isGraphQL) {
11737
11718
await state.write.key(state.id).schedule(jobOptions, noop);
11738
11719
}
11720
+ // Guarantee at least 3000ms between requests that trigger notifications
11739
11721
if (isWrite && state.triggersNotification(pathname)) {
11740
11722
await state.notifications.key(state.id).schedule(jobOptions, noop);
11741
11723
}
11724
+ // Guarantee at least 2000ms between search requests
11742
11725
if (isSearch) {
11743
11726
await state.search.key(state.id).schedule(jobOptions, noop);
11744
11727
}
11745
11728
const req = state.global.key(state.id).schedule(jobOptions, request, options);
11746
11729
if (isGraphQL) {
11747
11730
const res = await req;
11748
- if (res.data.errors != null && // @ts-expect-error
11749
- res.data.errors.some((error) => error.type === "RATE_LIMITED")) {
11731
+ if (res.data.errors != null &&
11732
+ // @ts-expect-error
11733
+ res.data.errors.some(error => error.type === "RATE_LIMITED")) {
11750
11734
const error = Object.assign(new Error("GraphQL Rate Limit Exceeded"), {
11751
11735
response: res,
11752
11736
data: res.data
@@ -11757,41 +11741,37 @@ async function doRequest(state, request, options) {
11757
11741
return req;
11758
11742
}
11759
11743
11760
- // pkg/dist-src/generated/triggers-notification-paths.js
11761
- var triggers_notification_paths_default = [
11762
- "/orgs/{org}/invitations",
11763
- "/orgs/{org}/invitations/{invitation_id}",
11764
- "/orgs/{org}/teams/{team_slug}/discussions",
11765
- "/orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments",
11766
- "/repos/{owner}/{repo}/collaborators/{username}",
11767
- "/repos/{owner}/{repo}/commits/{commit_sha}/comments",
11768
- "/repos/{owner}/{repo}/issues",
11769
- "/repos/{owner}/{repo}/issues/{issue_number}/comments",
11770
- "/repos/{owner}/{repo}/pulls",
11771
- "/repos/{owner}/{repo}/pulls/{pull_number}/comments",
11772
- "/repos/{owner}/{repo}/pulls/{pull_number}/comments/{comment_id}/replies",
11773
- "/repos/{owner}/{repo}/pulls/{pull_number}/merge",
11774
- "/repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers",
11775
- "/repos/{owner}/{repo}/pulls/{pull_number}/reviews",
11776
- "/repos/{owner}/{repo}/releases",
11777
- "/teams/{team_id}/discussions",
11778
- "/teams/{team_id}/discussions/{discussion_number}/comments"
11779
- ];
11744
+ var triggersNotificationPaths = ["/orgs/{org}/invitations", "/orgs/{org}/invitations/{invitation_id}", "/orgs/{org}/teams/{team_slug}/discussions", "/orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments", "/repos/{owner}/{repo}/collaborators/{username}", "/repos/{owner}/{repo}/commits/{commit_sha}/comments", "/repos/{owner}/{repo}/issues", "/repos/{owner}/{repo}/issues/{issue_number}/comments", "/repos/{owner}/{repo}/pulls", "/repos/{owner}/{repo}/pulls/{pull_number}/comments", "/repos/{owner}/{repo}/pulls/{pull_number}/comments/{comment_id}/replies", "/repos/{owner}/{repo}/pulls/{pull_number}/merge", "/repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers", "/repos/{owner}/{repo}/pulls/{pull_number}/reviews", "/repos/{owner}/{repo}/releases", "/teams/{team_id}/discussions", "/teams/{team_id}/discussions/{discussion_number}/comments"];
11780
11745
11781
- // pkg/dist-src/route-matcher.js
11782
11746
function routeMatcher(paths) {
11783
- const regexes = paths.map(
11784
- (path) => path.split("/").map((c) => c.startsWith("{") ? "(?:.+?)" : c).join("/")
11785
- );
11786
- const regex2 = `^(?:${regexes.map((r) => `(?:${r})`).join("|")})[^/]*$`;
11787
- return new RegExp(regex2, "i");
11747
+ // EXAMPLE. For the following paths:
11748
+ /* [
11749
+ "/orgs/{org}/invitations",
11750
+ "/repos/{owner}/{repo}/collaborators/{username}"
11751
+ ] */
11752
+ const regexes = paths.map(path => path.split("/").map(c => c.startsWith("{") ? "(?:.+?)" : c).join("/"));
11753
+ // 'regexes' would contain:
11754
+ /* [
11755
+ '/orgs/(?:.+?)/invitations',
11756
+ '/repos/(?:.+?)/(?:.+?)/collaborators/(?:.+?)'
11757
+ ] */
11758
+ const regex = `^(?:${regexes.map(r => `(?:${r})`).join("|")})[^/]*$`;
11759
+ // 'regex' would contain:
11760
+ /*
11761
+ ^(?:(?:\/orgs\/(?:.+?)\/invitations)|(?:\/repos\/(?:.+?)\/(?:.+?)\/collaborators\/(?:.+?)))[^\/]*$
11762
+ It may look scary, but paste it into https://www.debuggex.com/
11763
+ and it will make a lot more sense!
11764
+ */
11765
+ return new RegExp(regex, "i");
11788
11766
}
11789
11767
11790
- // pkg/dist-src/index.js
11791
- var regex = routeMatcher(triggers_notification_paths_default);
11792
- var triggersNotification = regex.test.bind(regex);
11793
- var groups = {};
11794
- var createGroups = function(Bottleneck, common) {
11768
+ // @ts-expect-error
11769
+ // Workaround to allow tests to directly access the triggersNotification function.
11770
+ const regex = routeMatcher(triggersNotificationPaths);
11771
+ const triggersNotification = regex.test.bind(regex);
11772
+ const groups = {};
11773
+ // @ts-expect-error
11774
+ const createGroups = function (Bottleneck, common) {
11795
11775
groups.global = new Bottleneck.Group({
11796
11776
id: "octokit-global",
11797
11777
maxConcurrent: 10,
@@ -11800,50 +11780,62 @@ var createGroups = function(Bottleneck, common) {
11800
11780
groups.search = new Bottleneck.Group({
11801
11781
id: "octokit-search",
11802
11782
maxConcurrent: 1,
11803
- minTime: 2e3 ,
11783
+ minTime: 2000 ,
11804
11784
...common
11805
11785
});
11806
11786
groups.write = new Bottleneck.Group({
11807
11787
id: "octokit-write",
11808
11788
maxConcurrent: 1,
11809
- minTime: 1e3 ,
11789
+ minTime: 1000 ,
11810
11790
...common
11811
11791
});
11812
11792
groups.notifications = new Bottleneck.Group({
11813
11793
id: "octokit-notifications",
11814
11794
maxConcurrent: 1,
11815
- minTime: 3e3 ,
11795
+ minTime: 3000 ,
11816
11796
...common
11817
11797
});
11818
11798
};
11819
11799
function throttling(octokit, octokitOptions) {
11820
11800
const {
11821
11801
enabled = true,
11822
- Bottleneck = import_light.default ,
11802
+ Bottleneck = BottleneckLight ,
11823
11803
id = "no-id",
11824
- timeout = 1e3 * 60 * 2,
11804
+ timeout = 1000 * 60 * 2,
11825
11805
// Redis TTL: 2 minutes
11826
11806
connection
11827
11807
} = octokitOptions.throttle || {};
11828
11808
if (!enabled) {
11829
11809
return {};
11830
11810
}
11831
- const common = { connection, timeout };
11811
+ const common = {
11812
+ connection,
11813
+ timeout
11814
+ };
11832
11815
if (groups.global == null) {
11833
11816
createGroups(Bottleneck, common);
11834
11817
}
11835
- const state = Object.assign(
11836
- {
11837
- clustering: connection != null,
11838
- triggersNotification,
11839
- fallbackSecondaryRateRetryAfter: 60,
11840
- retryAfterBaseValue: 1e3,
11841
- retryLimiter: new Bottleneck(),
11842
- id,
11843
- ...groups
11844
- },
11845
- octokitOptions.throttle
11846
- );
11818
+ if (octokitOptions.throttle && octokitOptions.throttle.minimalSecondaryRateRetryAfter) {
11819
+ octokit.log.warn("[@octokit/plugin-throttling] `options.throttle.minimalSecondaryRateRetryAfter` is deprecated, please use `options.throttle.fallbackSecondaryRateRetryAfter` instead");
11820
+ octokitOptions.throttle.fallbackSecondaryRateRetryAfter = octokitOptions.throttle.minimalSecondaryRateRetryAfter;
11821
+ delete octokitOptions.throttle.minimalSecondaryRateRetryAfter;
11822
+ }
11823
+ if (octokitOptions.throttle && octokitOptions.throttle.onAbuseLimit) {
11824
+ octokit.log.warn("[@octokit/plugin-throttling] `onAbuseLimit()` is deprecated and will be removed in a future release of `@octokit/plugin-throttling`, please use the `onSecondaryRateLimit` handler instead");
11825
+ // @ts-ignore types don't allow for both properties to be set
11826
+ octokitOptions.throttle.onSecondaryRateLimit = octokitOptions.throttle.onAbuseLimit;
11827
+ // @ts-ignore
11828
+ delete octokitOptions.throttle.onAbuseLimit;
11829
+ }
11830
+ const state = Object.assign({
11831
+ clustering: connection != null,
11832
+ triggersNotification,
11833
+ fallbackSecondaryRateRetryAfter: 60,
11834
+ retryAfterBaseValue: 1000,
11835
+ retryLimiter: new Bottleneck(),
11836
+ id,
11837
+ ...groups
11838
+ }, octokitOptions.throttle);
11847
11839
if (typeof state.onSecondaryRateLimit !== "function" || typeof state.onRateLimit !== "function") {
11848
11840
throw new Error(`octokit/plugin-throttling error:
11849
11841
You must pass the onSecondaryRateLimit and onRateLimit error handlers.
@@ -11859,65 +11851,69 @@ function throttling(octokit, octokitOptions) {
11859
11851
}
11860
11852
const events = {};
11861
11853
const emitter = new Bottleneck.Events(events);
11854
+ // @ts-expect-error
11862
11855
events.on("secondary-limit", state.onSecondaryRateLimit);
11856
+ // @ts-expect-error
11863
11857
events.on("rate-limit", state.onRateLimit);
11864
- events.on(
11865
- "error",
11866
- (e) => octokit.log.warn("Error in throttling-plugin limit handler", e)
11867
- );
11868
- state.retryLimiter.on("failed", async function(error, info) {
11869
- const [state2, request, options] = info.args;
11870
- const { pathname } = new URL(options.url, "http://github.test");
11858
+ // @ts-expect-error
11859
+ events.on("error", e => octokit.log.warn("Error in throttling-plugin limit handler", e));
11860
+ // @ts-expect-error
11861
+ state.retryLimiter.on("failed", async function (error, info) {
11862
+ const [state, request, options] = info.args;
11863
+ const {
11864
+ pathname
11865
+ } = new URL(options.url, "http://github.test");
11871
11866
const shouldRetryGraphQL = pathname.startsWith("/graphql") && error.status !== 401;
11872
11867
if (!(shouldRetryGraphQL || error.status === 403)) {
11873
11868
return;
11874
11869
}
11875
11870
const retryCount = ~~request.retryCount;
11876
11871
request.retryCount = retryCount;
11872
+ // backward compatibility
11877
11873
options.request.retryCount = retryCount;
11878
- const { wantRetry, retryAfter = 0 } = await async function() {
11874
+ const {
11875
+ wantRetry,
11876
+ retryAfter = 0
11877
+ } = await async function () {
11879
11878
if (/\bsecondary rate\b/i.test(error.message)) {
11880
- const retryAfter2 = Number(error.response.headers["retry-after"]) || state2.fallbackSecondaryRateRetryAfter;
11881
- const wantRetry2 = await emitter.trigger(
11882
- "secondary-limit",
11883
- retryAfter2,
11884
- options,
11885
- octokit,
11886
- retryCount
11887
- );
11888
- return { wantRetry: wantRetry2, retryAfter: retryAfter2 };
11879
+ // The user has hit the secondary rate limit. (REST and GraphQL)
11880
+ // https://docs.github.com/en/rest/overview/resources-in-the-rest-api#secondary-rate-limits
11881
+ // The Retry-After header can sometimes be blank when hitting a secondary rate limit,
11882
+ // but is always present after 2-3s, so make sure to set `retryAfter` to at least 5s by default.
11883
+ const retryAfter = Number(error.response.headers["retry-after"]) || state.fallbackSecondaryRateRetryAfter;
11884
+ const wantRetry = await emitter.trigger("secondary-limit", retryAfter, options, octokit, retryCount);
11885
+ return {
11886
+ wantRetry,
11887
+ retryAfter
11888
+ };
11889
11889
}
11890
11890
if (error.response.headers != null && error.response.headers["x-ratelimit-remaining"] === "0") {
11891
- const rateLimitReset = new Date(
11892
- ~~error.response.headers["x-ratelimit-reset"] * 1e3
11893
- ).getTime();
11894
- const retryAfter2 = Math.max(
11895
- Math.ceil((rateLimitReset - Date.now()) / 1e3),
11896
- 0
11897
- );
11898
- const wantRetry2 = await emitter.trigger(
11899
- "rate-limit",
11900
- retryAfter2,
11901
- options,
11902
- octokit,
11903
- retryCount
11904
- );
11905
- return { wantRetry: wantRetry2, retryAfter: retryAfter2 };
11891
+ // The user has used all their allowed calls for the current time period (REST and GraphQL)
11892
+ // https://docs.github.com/en/rest/reference/rate-limit (REST)
11893
+ // https://docs.github.com/en/graphql/overview/resource-limitations#rate-limit (GraphQL)
11894
+ const rateLimitReset = new Date(~~error.response.headers["x-ratelimit-reset"] * 1000).getTime();
11895
+ const retryAfter = Math.max(Math.ceil((rateLimitReset - Date.now()) / 1000), 0);
11896
+ const wantRetry = await emitter.trigger("rate-limit", retryAfter, options, octokit, retryCount);
11897
+ return {
11898
+ wantRetry,
11899
+ retryAfter
11900
+ };
11906
11901
}
11907
11902
return {};
11908
11903
}();
11909
11904
if (wantRetry) {
11910
11905
request.retryCount++;
11911
- return retryAfter * state2 .retryAfterBaseValue;
11906
+ return retryAfter * state .retryAfterBaseValue;
11912
11907
}
11913
11908
});
11914
11909
octokit.hook.wrap("request", wrapRequest.bind(null, state));
11915
11910
return {};
11916
11911
}
11917
11912
throttling.VERSION = VERSION;
11918
11913
throttling.triggersNotification = triggersNotification;
11919
- // Annotate the CommonJS export names for ESM import in node:
11920
- 0 && (0);
11914
+
11915
+ exports.throttling = throttling;
11916
+ //# sourceMappingURL=index.js.map
11921
11917
11922
11918
11923
11919
/***/ }),
@@ -44082,7 +44078,7 @@ var import_plugin_retry = __nccwpck_require__(6298);
44082
44078
var import_plugin_throttling = __nccwpck_require__(9968);
44083
44079
44084
44080
// pkg/dist-src/version.js
44085
- var VERSION = "2.0.21 ";
44081
+ var VERSION = "2.0.22 ";
44086
44082
44087
44083
// pkg/dist-src/octokit.js
44088
44084
var Octokit = import_core.Octokit.plugin(
0 commit comments