Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

@octokit/plugin-retry

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@octokit/plugin-retry - npm Package Compare versions

Comparing version
8.0.3
to
8.1.0
dist-src/bottleneck.d.js
+13
import type { RequestError } from "@octokit/request-error";
export interface RetryPlugin {
retry: {
retryRequest: (error: RequestError, retries: number, retryAfter: number) => RequestError;
};
}
export interface RetryOptions {
enabled?: boolean;
retryAfterBaseValue?: number;
doNotRetry?: number[];
retries?: number;
}
export type RetryState = Required<RetryOptions>;
+14
-10

@@ -5,4 +5,7 @@ // pkg/dist-src/version.js

// pkg/dist-src/error-request.js
function isRequestError(error) {
return error.request !== void 0;
}
async function errorRequest(state, octokit, error, options) {
if (!error.request || !error.request.request) {
if (!isRequestError(error) || !error?.request.request) {
throw error;

@@ -19,3 +22,3 @@ }

// pkg/dist-src/wrap-request.js
import Bottleneck from "bottleneck/light.js";
import Bottleneck, {} from "bottleneck/light.js";
import { RequestError } from "@octokit/request-error";

@@ -25,4 +28,4 @@ async function wrapRequest(state, octokit, request, options) {

limiter.on("failed", function(error, info) {
const maxRetries = ~~error.request.request.retries;
const after = ~~error.request.request.retryAfter;
const maxRetries = ~~error.request.request?.retries;
const after = ~~error.request.request?.retryAfter;
options.request.retryCount = info.retryCount + 1;

@@ -39,3 +42,3 @@ if (maxRetries > info.retryCount) {

async function requestWithGraphqlErrorHandling(state, octokit, request, options) {
const response = await request(request, options);
const response = await request(options);
if (response.data && response.data.errors && response.data.errors.length > 0 && /Something went wrong while executing your query/.test(

@@ -64,7 +67,3 @@ response.data.errors[0].message

);
if (state.enabled) {
octokit.hook.error("request", errorRequest.bind(null, state, octokit));
octokit.hook.wrap("request", wrapRequest.bind(null, state, octokit));
}
return {
const retryPlugin = {
retry: {

@@ -80,2 +79,7 @@ retryRequest: (error, retries, retryAfter) => {

};
if (state.enabled) {
octokit.hook.error("request", errorRequest.bind(null, state, retryPlugin));
octokit.hook.wrap("request", wrapRequest.bind(null, state, retryPlugin));
}
return retryPlugin;
}

@@ -82,0 +86,0 @@ retry.VERSION = VERSION;

{
"version": 3,
"sources": ["../dist-src/version.js", "../dist-src/error-request.js", "../dist-src/wrap-request.js", "../dist-src/index.js"],
"sourcesContent": ["const VERSION = \"0.0.0-development\";\nexport {\n VERSION\n};\n", "async function errorRequest(state, octokit, error, options) {\n if (!error.request || !error.request.request) {\n throw error;\n }\n if (error.status >= 400 && !state.doNotRetry.includes(error.status)) {\n const retries = options.request.retries != null ? options.request.retries : state.retries;\n const retryAfter = Math.pow((options.request.retryCount || 0) + 1, 2);\n throw octokit.retry.retryRequest(error, retries, retryAfter);\n }\n throw error;\n}\nexport {\n errorRequest\n};\n", "import Bottleneck from \"bottleneck/light.js\";\nimport { RequestError } from \"@octokit/request-error\";\nimport { errorRequest } from \"./error-request.js\";\nasync function wrapRequest(state, octokit, request, options) {\n const limiter = new Bottleneck();\n limiter.on(\"failed\", function(error, info) {\n const maxRetries = ~~error.request.request.retries;\n const after = ~~error.request.request.retryAfter;\n options.request.retryCount = info.retryCount + 1;\n if (maxRetries > info.retryCount) {\n return after * state.retryAfterBaseValue;\n }\n });\n return limiter.schedule(\n requestWithGraphqlErrorHandling.bind(null, state, octokit, request),\n options\n );\n}\nasync function requestWithGraphqlErrorHandling(state, octokit, request, options) {\n const response = await request(request, options);\n if (response.data && response.data.errors && response.data.errors.length > 0 && /Something went wrong while executing your query/.test(\n response.data.errors[0].message\n )) {\n const error = new RequestError(response.data.errors[0].message, 500, {\n request: options,\n response\n });\n return errorRequest(state, octokit, error, options);\n }\n return response;\n}\nexport {\n wrapRequest\n};\n", "import { VERSION } from \"./version.js\";\nimport { errorRequest } from \"./error-request.js\";\nimport { wrapRequest } from \"./wrap-request.js\";\nimport { VERSION as VERSION2 } from \"./version.js\";\nfunction retry(octokit, octokitOptions) {\n const state = Object.assign(\n {\n enabled: true,\n retryAfterBaseValue: 1e3,\n doNotRetry: [400, 401, 403, 404, 410, 422, 451],\n retries: 3\n },\n octokitOptions.retry\n );\n if (state.enabled) {\n octokit.hook.error(\"request\", errorRequest.bind(null, state, octokit));\n octokit.hook.wrap(\"request\", wrapRequest.bind(null, state, octokit));\n }\n return {\n retry: {\n retryRequest: (error, retries, retryAfter) => {\n error.request.request = Object.assign({}, error.request.request, {\n retries,\n retryAfter\n });\n return error;\n }\n }\n };\n}\nretry.VERSION = VERSION;\nexport {\n VERSION2 as VERSION,\n retry\n};\n"],
"mappings": ";AAAA,IAAM,UAAU;;;ACAhB,eAAe,aAAa,OAAO,SAAS,OAAO,SAAS;AAC1D,MAAI,CAAC,MAAM,WAAW,CAAC,MAAM,QAAQ,SAAS;AAC5C,UAAM;AAAA,EACR;AACA,MAAI,MAAM,UAAU,OAAO,CAAC,MAAM,WAAW,SAAS,MAAM,MAAM,GAAG;AACnE,UAAM,UAAU,QAAQ,QAAQ,WAAW,OAAO,QAAQ,QAAQ,UAAU,MAAM;AAClF,UAAM,aAAa,KAAK,KAAK,QAAQ,QAAQ,cAAc,KAAK,GAAG,CAAC;AACpE,UAAM,QAAQ,MAAM,aAAa,OAAO,SAAS,UAAU;AAAA,EAC7D;AACA,QAAM;AACR;;;ACVA,OAAO,gBAAgB;AACvB,SAAS,oBAAoB;AAE7B,eAAe,YAAY,OAAO,SAAS,SAAS,SAAS;AAC3D,QAAM,UAAU,IAAI,WAAW;AAC/B,UAAQ,GAAG,UAAU,SAAS,OAAO,MAAM;AACzC,UAAM,aAAa,CAAC,CAAC,MAAM,QAAQ,QAAQ;AAC3C,UAAM,QAAQ,CAAC,CAAC,MAAM,QAAQ,QAAQ;AACtC,YAAQ,QAAQ,aAAa,KAAK,aAAa;AAC/C,QAAI,aAAa,KAAK,YAAY;AAChC,aAAO,QAAQ,MAAM;AAAA,IACvB;AAAA,EACF,CAAC;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";\nfunction isRequestError(error) {\n return error.request !== void 0;\n}\nasync function errorRequest(state, octokit, error, options) {\n if (!isRequestError(error) || !error?.request.request) {\n throw error;\n }\n if (error.status >= 400 && !state.doNotRetry.includes(error.status)) {\n const retries = options.request.retries != null ? options.request.retries : state.retries;\n const retryAfter = Math.pow((options.request.retryCount || 0) + 1, 2);\n throw octokit.retry.retryRequest(error, retries, retryAfter);\n }\n throw error;\n}\nexport {\n errorRequest,\n isRequestError\n};\n", "import Bottleneck, {} from \"bottleneck/light.js\";\nimport { RequestError } from \"@octokit/request-error\";\nimport { errorRequest } from \"./error-request.js\";\nasync function wrapRequest(state, octokit, request, options) {\n const limiter = new Bottleneck();\n limiter.on(\"failed\", function(error, info) {\n const maxRetries = ~~error.request.request?.retries;\n const after = ~~error.request.request?.retryAfter;\n options.request.retryCount = info.retryCount + 1;\n if (maxRetries > info.retryCount) {\n return after * state.retryAfterBaseValue;\n }\n });\n return limiter.schedule(\n requestWithGraphqlErrorHandling.bind(null, state, octokit, request),\n options\n );\n}\nasync function requestWithGraphqlErrorHandling(state, octokit, request, options) {\n const response = await request(options);\n if (response.data && response.data.errors && response.data.errors.length > 0 && /Something went wrong while executing your query/.test(\n response.data.errors[0].message\n )) {\n const error = new RequestError(response.data.errors[0].message, 500, {\n request: options,\n response\n });\n return errorRequest(state, octokit, error, options);\n }\n return response;\n}\nexport {\n wrapRequest\n};\n", "import { VERSION } from \"./version.js\";\nimport { errorRequest } from \"./error-request.js\";\nimport { wrapRequest } from \"./wrap-request.js\";\nimport { VERSION as VERSION2 } from \"./version.js\";\nfunction retry(octokit, octokitOptions) {\n const state = Object.assign(\n {\n enabled: true,\n retryAfterBaseValue: 1e3,\n doNotRetry: [400, 401, 403, 404, 410, 422, 451],\n retries: 3\n },\n octokitOptions.retry\n );\n const retryPlugin = {\n retry: {\n retryRequest: (error, retries, retryAfter) => {\n error.request.request = Object.assign({}, error.request.request, {\n retries,\n retryAfter\n });\n return error;\n }\n }\n };\n if (state.enabled) {\n octokit.hook.error(\"request\", errorRequest.bind(null, state, retryPlugin));\n octokit.hook.wrap(\"request\", wrapRequest.bind(null, state, retryPlugin));\n }\n return retryPlugin;\n}\nretry.VERSION = VERSION;\nexport {\n VERSION2 as VERSION,\n retry\n};\n"],
"mappings": ";AAAA,IAAM,UAAU;;;ACChB,SAAS,eAAe,OAAO;AAC7B,SAAO,MAAM,YAAY;AAC3B;AACA,eAAe,aAAa,OAAO,SAAS,OAAO,SAAS;AAC1D,MAAI,CAAC,eAAe,KAAK,KAAK,CAAC,OAAO,QAAQ,SAAS;AACrD,UAAM;AAAA,EACR;AACA,MAAI,MAAM,UAAU,OAAO,CAAC,MAAM,WAAW,SAAS,MAAM,MAAM,GAAG;AACnE,UAAM,UAAU,QAAQ,QAAQ,WAAW,OAAO,QAAQ,QAAQ,UAAU,MAAM;AAClF,UAAM,aAAa,KAAK,KAAK,QAAQ,QAAQ,cAAc,KAAK,GAAG,CAAC;AACpE,UAAM,QAAQ,MAAM,aAAa,OAAO,SAAS,UAAU;AAAA,EAC7D;AACA,QAAM;AACR;;;ACdA,OAAO,oBAAoB;AAC3B,SAAS,oBAAoB;AAE7B,eAAe,YAAY,OAAO,SAAS,SAAS,SAAS;AAC3D,QAAM,UAAU,IAAI,WAAW;AAC/B,UAAQ,GAAG,UAAU,SAAS,OAAO,MAAM;AACzC,UAAM,aAAa,CAAC,CAAC,MAAM,QAAQ,SAAS;AAC5C,UAAM,QAAQ,CAAC,CAAC,MAAM,QAAQ,SAAS;AACvC,YAAQ,QAAQ,aAAa,KAAK,aAAa;AAC/C,QAAI,aAAa,KAAK,YAAY;AAChC,aAAO,QAAQ,MAAM;AAAA,IACvB;AAAA,EACF,CAAC;AACD,SAAO,QAAQ;AAAA,IACb,gCAAgC,KAAK,MAAM,OAAO,SAAS,OAAO;AAAA,IAClE;AAAA,EACF;AACF;AACA,eAAe,gCAAgC,OAAO,SAAS,SAAS,SAAS;AAC/E,QAAM,WAAW,MAAM,QAAQ,OAAO;AACtC,MAAI,SAAS,QAAQ,SAAS,KAAK,UAAU,SAAS,KAAK,OAAO,SAAS,KAAK,kDAAkD;AAAA,IAChI,SAAS,KAAK,OAAO,CAAC,EAAE;AAAA,EAC1B,GAAG;AACD,UAAM,QAAQ,IAAI,aAAa,SAAS,KAAK,OAAO,CAAC,EAAE,SAAS,KAAK;AAAA,MACnE,SAAS;AAAA,MACT;AAAA,IACF,CAAC;AACD,WAAO,aAAa,OAAO,SAAS,OAAO,OAAO;AAAA,EACpD;AACA,SAAO;AACT;;;AC1BA,SAAS,MAAM,SAAS,gBAAgB;AACtC,QAAM,QAAQ,OAAO;AAAA,IACnB;AAAA,MACE,SAAS;AAAA,MACT,qBAAqB;AAAA,MACrB,YAAY,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,GAAG;AAAA,MAC9C,SAAS;AAAA,IACX;AAAA,IACA,eAAe;AAAA,EACjB;AACA,QAAM,cAAc;AAAA,IAClB,OAAO;AAAA,MACL,cAAc,CAAC,OAAO,SAAS,eAAe;AAC5C,cAAM,QAAQ,UAAU,OAAO,OAAO,CAAC,GAAG,MAAM,QAAQ,SAAS;AAAA,UAC/D;AAAA,UACA;AAAA,QACF,CAAC;AACD,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACA,MAAI,MAAM,SAAS;AACjB,YAAQ,KAAK,MAAM,WAAW,aAAa,KAAK,MAAM,OAAO,WAAW,CAAC;AACzE,YAAQ,KAAK,KAAK,WAAW,YAAY,KAAK,MAAM,OAAO,WAAW,CAAC;AAAA,EACzE;AACA,SAAO;AACT;AACA,MAAM,UAAU;",
"names": []
}

@@ -0,3 +1,7 @@

import {} from "./types.js";
function isRequestError(error) {
return error.request !== void 0;
}
async function errorRequest(state, octokit, error, options) {
if (!error.request || !error.request.request) {
if (!isRequestError(error) || !error?.request.request) {
throw error;

@@ -13,3 +17,4 @@ }

export {
errorRequest
errorRequest,
isRequestError
};

@@ -15,7 +15,3 @@ import { VERSION } from "./version.js";

);
if (state.enabled) {
octokit.hook.error("request", errorRequest.bind(null, state, octokit));
octokit.hook.wrap("request", wrapRequest.bind(null, state, octokit));
}
return {
const retryPlugin = {
retry: {

@@ -31,2 +27,7 @@ retryRequest: (error, retries, retryAfter) => {

};
if (state.enabled) {
octokit.hook.error("request", errorRequest.bind(null, state, retryPlugin));
octokit.hook.wrap("request", wrapRequest.bind(null, state, retryPlugin));
}
return retryPlugin;
}

@@ -33,0 +34,0 @@ retry.VERSION = VERSION;

@@ -1,4 +0,4 @@

const VERSION = "8.0.3";
const VERSION = "8.1.0";
export {
VERSION
};

@@ -1,2 +0,2 @@

import Bottleneck from "bottleneck/light.js";
import Bottleneck, {} from "bottleneck/light.js";
import { RequestError } from "@octokit/request-error";

@@ -7,4 +7,4 @@ import { errorRequest } from "./error-request.js";

limiter.on("failed", function(error, info) {
const maxRetries = ~~error.request.request.retries;
const after = ~~error.request.request.retryAfter;
const maxRetries = ~~error.request.request?.retries;
const after = ~~error.request.request?.retryAfter;
options.request.retryCount = info.retryCount + 1;

@@ -21,3 +21,3 @@ if (maxRetries > info.retryCount) {

async function requestWithGraphqlErrorHandling(state, octokit, request, options) {
const response = await request(request, options);
const response = await request(options);
if (response.data && response.data.errors && response.data.errors.length > 0 && /Something went wrong while executing your query/.test(

@@ -24,0 +24,0 @@ response.data.errors[0].message

@@ -1,1 +0,7 @@

export declare function errorRequest(state: any, octokit: any, error: any, options: any): Promise<void>;
import { type RetryPlugin, type RetryState } from "./types.js";
import type { RequestRequestOptions } from "@octokit/types";
import type { RequestError } from "@octokit/request-error";
export declare function isRequestError(error: any): error is RequestError;
export declare function errorRequest(state: RetryState, octokit: RetryPlugin, error: RequestError | Error, options: {
request: RequestRequestOptions;
}): Promise<any>;

@@ -1,11 +0,13 @@

import type { Octokit } from "@octokit/core";
import type { RequestError } from "@octokit/request-error";
import type { Octokit, OctokitOptions } from "@octokit/core";
import type { RetryOptions, RetryPlugin } from "./types.js";
export { VERSION } from "./version.js";
export declare function retry(octokit: Octokit, octokitOptions: any): {
retry: {
retryRequest: (error: RequestError, retries: number, retryAfter: number) => RequestError;
};
};
export declare function retry(octokit: Octokit, octokitOptions: OctokitOptions): RetryPlugin;
export declare namespace retry {
var VERSION: string;
}
declare module "@octokit/core/types" {
interface OctokitOptions {
retry?: RetryOptions;
}
}
export type { RetryPlugin, RetryOptions };

@@ -1,1 +0,1 @@

export declare const VERSION = "8.0.3";
export declare const VERSION = "8.1.0";

@@ -1,1 +0,5 @@

export declare function wrapRequest(state: any, octokit: any, request: any, options: any): Promise<any>;
import type { RetryPlugin, RetryState } from "./types.js";
import type { EndpointDefaults, OctokitResponse } from "@octokit/types";
type RequestHook = (options: Required<EndpointDefaults>) => OctokitResponse<any, number> | Promise<OctokitResponse<any, number>>;
export declare function wrapRequest(state: RetryState, octokit: RetryPlugin, request: RequestHook, options: Required<EndpointDefaults>): Promise<OctokitResponse<any, number>>;
export {};
{
"name": "@octokit/plugin-retry",
"version": "8.0.3",
"version": "8.1.0",
"publishConfig": {

@@ -24,9 +24,9 @@ "access": "public",

"@octokit/tsconfig": "^4.0.0",
"@types/node": "^22.0.0",
"@types/node": "^24.0.0",
"@vitest/coverage-v8": "^4.0.0",
"esbuild": "^0.25.0",
"fetch-mock": "^12.0.0",
"glob": "^11.0.0",
"prettier": "3.5.3",
"prettier": "3.6.2",
"semantic-release-plugin-update-version-in-files": "^2.0.0",
"tinyglobby": "^0.2.15",
"typescript": "^5.0.0",

@@ -33,0 +33,0 @@ "vitest": "^4.0.0"