@@ -1375,6 +1375,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13751375Object.defineProperty(exports, "__esModule", ({ value: true }));
13761376exports.GitHubHelper = void 0;
13771377const core = __importStar(__nccwpck_require__(7484));
1378+ const request_error_1 = __nccwpck_require__(1015);
13781379const octokit_client_1 = __nccwpck_require__(3489);
13791380const p_limit_1 = __importDefault(__nccwpck_require__(7989));
13801381const utils = __importStar(__nccwpck_require__(9277));
@@ -1501,20 +1502,28 @@ class GitHubHelper {
15011502 return __awaiter(this, void 0, void 0, function* () {
15021503 // Create or update the pull request
15031504 const pull = yield this.createOrUpdate(inputs, baseRepository, headRepository);
1505+ // After creating a new PR, follow-up API calls can fail with a 422
1506+ // "Could not resolve to a node" error due to GitHub API eventual
1507+ // consistency. Wrap post-creation calls with targeted retry logic.
1508+ // See: https://github.com/peter-evans/create-pull-request/issues/4321
1509+ const isEventualConsistencyError = (e) => e instanceof request_error_1.RequestError &&
1510+ e.status === 422 &&
1511+ e.message.includes('Could not resolve to a node');
1512+ const withRetryForNewPr = (fn) => pull.created ? utils.retryWithBackoff(fn, isEventualConsistencyError) : fn();
15041513 // Apply milestone
15051514 if (inputs.milestone) {
15061515 core.info(`Applying milestone '${inputs.milestone}'`);
1507- yield this.octokit.rest.issues.update(Object.assign(Object.assign({}, this.parseRepository(baseRepository)), { issue_number: pull.number, milestone: inputs.milestone }));
1516+ yield withRetryForNewPr(() => this.octokit.rest.issues.update(Object.assign(Object.assign({}, this.parseRepository(baseRepository)), { issue_number: pull.number, milestone: inputs.milestone }) ));
15081517 }
15091518 // Apply labels
15101519 if (inputs.labels.length > 0) {
15111520 core.info(`Applying labels '${inputs.labels}'`);
1512- yield this.octokit.rest.issues.addLabels(Object.assign(Object.assign({}, this.parseRepository(baseRepository)), { issue_number: pull.number, labels: inputs.labels }));
1521+ yield withRetryForNewPr(() => this.octokit.rest.issues.addLabels(Object.assign(Object.assign({}, this.parseRepository(baseRepository)), { issue_number: pull.number, labels: inputs.labels }) ));
15131522 }
15141523 // Apply assignees
15151524 if (inputs.assignees.length > 0) {
15161525 core.info(`Applying assignees '${inputs.assignees}'`);
1517- yield this.octokit.rest.issues.addAssignees(Object.assign(Object.assign({}, this.parseRepository(baseRepository)), { issue_number: pull.number, assignees: inputs.assignees }));
1526+ yield withRetryForNewPr(() => this.octokit.rest.issues.addAssignees(Object.assign(Object.assign({}, this.parseRepository(baseRepository)), { issue_number: pull.number, assignees: inputs.assignees }) ));
15181527 }
15191528 // Request reviewers and team reviewers
15201529 const requestReviewersParams = {};
@@ -1529,7 +1538,7 @@ class GitHubHelper {
15291538 }
15301539 if (Object.keys(requestReviewersParams).length > 0) {
15311540 try {
1532- yield this.octokit.rest.pulls.requestReviewers(Object.assign(Object.assign(Object.assign({}, this.parseRepository(baseRepository)), { pull_number: pull.number }), requestReviewersParams));
1541+ yield withRetryForNewPr(() => this.octokit.rest.pulls.requestReviewers(Object.assign(Object.assign(Object.assign({}, this.parseRepository(baseRepository)), { pull_number: pull.number }), requestReviewersParams) ));
15331542 }
15341543 catch (e) {
15351544 if (utils.getErrorMessage(e).includes(ERROR_PR_REVIEW_TOKEN_SCOPE)) {
@@ -1900,6 +1909,15 @@ var __importStar = (this && this.__importStar) || (function () {
19001909 return result;
19011910 };
19021911})();
1912+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
1913+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
1914+ return new (P || (P = Promise))(function (resolve, reject) {
1915+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
1916+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
1917+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
1918+ step((generator = generator.apply(thisArg, _arguments || [])).next());
1919+ });
1920+ };
19031921Object.defineProperty(exports, "__esModule", ({ value: true }));
19041922exports.isSelfHosted = void 0;
19051923exports.getInputAsArray = getInputAsArray;
@@ -1913,6 +1931,7 @@ exports.parseDisplayNameEmail = parseDisplayNameEmail;
19131931exports.fileExistsSync = fileExistsSync;
19141932exports.readFile = readFile;
19151933exports.getErrorMessage = getErrorMessage;
1934+ exports.retryWithBackoff = retryWithBackoff;
19161935const core = __importStar(__nccwpck_require__(7484));
19171936const fs = __importStar(__nccwpck_require__(9896));
19181937const path = __importStar(__nccwpck_require__(6928));
@@ -2014,6 +2033,26 @@ const isSelfHosted = () => process.env['RUNNER_ENVIRONMENT'] !== 'github-hosted'
20142033 (process.env['AGENT_ISSELFHOSTED'] === '1' ||
20152034 process.env['AGENT_ISSELFHOSTED'] === undefined);
20162035exports.isSelfHosted = isSelfHosted;
2036+ function retryWithBackoff(fn_1, shouldRetry_1) {
2037+ return __awaiter(this, arguments, void 0, function* (fn, shouldRetry, maxRetries = 2, delayMs = 1000) {
2038+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
2039+ try {
2040+ return yield fn();
2041+ }
2042+ catch (e) {
2043+ if (attempt < maxRetries && shouldRetry(e)) {
2044+ const delay = delayMs * Math.pow(2, attempt);
2045+ core.info(`Request failed (attempt ${attempt + 1}/${maxRetries + 1}), retrying in ${delay}ms...`);
2046+ yield new Promise(resolve => setTimeout(resolve, delay));
2047+ }
2048+ else {
2049+ throw e;
2050+ }
2051+ }
2052+ }
2053+ throw new Error('Unexpected: retry loop exited without return or throw');
2054+ });
2055+ }
20172056
20182057
20192058/***/ }),
@@ -32825,7 +32864,7 @@ async function fetchWrapper(requestOptions) {
3282532864 }
3282632865 }
3282732866 }
32828- const requestError = new dist_src/* RequestError */.G (message, 500, {
32867+ const requestError = new dist_src.RequestError (message, 500, {
3282932868 request: requestOptions
3283032869 });
3283132870 requestError.cause = error;
@@ -32857,21 +32896,21 @@ async function fetchWrapper(requestOptions) {
3285732896 if (status < 400) {
3285832897 return octokitResponse;
3285932898 }
32860- throw new dist_src/* RequestError */.G (fetchResponse.statusText, status, {
32899+ throw new dist_src.RequestError (fetchResponse.statusText, status, {
3286132900 response: octokitResponse,
3286232901 request: requestOptions
3286332902 });
3286432903 }
3286532904 if (status === 304) {
3286632905 octokitResponse.data = await getResponseData(fetchResponse);
32867- throw new dist_src/* RequestError */.G ("Not modified", status, {
32906+ throw new dist_src.RequestError ("Not modified", status, {
3286832907 response: octokitResponse,
3286932908 request: requestOptions
3287032909 });
3287132910 }
3287232911 if (status >= 400) {
3287332912 octokitResponse.data = await getResponseData(fetchResponse);
32874- throw new dist_src/* RequestError */.G (toErrorMessage(octokitResponse.data), status, {
32913+ throw new dist_src.RequestError (toErrorMessage(octokitResponse.data), status, {
3287532914 response: octokitResponse,
3287632915 request: requestOptions
3287732916 });
@@ -36220,7 +36259,7 @@ async function requestWithGraphqlErrorHandling(state, octokit, request, options)
3622036259 if (response.data && response.data.errors && response.data.errors.length > 0 && /Something went wrong while executing your query/.test(
3622136260 response.data.errors[0].message
3622236261 )) {
36223- const error = new _octokit_request_error__WEBPACK_IMPORTED_MODULE_1__/* .RequestError */ .G (response.data.errors[0].message, 500, {
36262+ const error = new _octokit_request_error__WEBPACK_IMPORTED_MODULE_1__.RequestError(response.data.errors[0].message, 500, {
3622436263 request: options,
3622536264 response
3622636265 });
@@ -36505,8 +36544,9 @@ throttling.triggersNotification = triggersNotification;
3650536544/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __nccwpck_require__) => {
3650636545
3650736546"use strict";
36547+ __nccwpck_require__.r(__webpack_exports__);
3650836548/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
36509- /* harmony export */ G : () => (/* binding */ RequestError)
36549+ /* harmony export */ RequestError : () => (/* binding */ RequestError)
3651036550/* harmony export */ });
3651136551class RequestError extends Error {
3651236552 name;
0 commit comments