Skip to content

Commit cfd90cf

Browse files
authored
Merge pull request #850 from semantic-release/fix/update-status-codes-for-retry-#839
2 parents d179bf4 + 355b8df commit cfd90cf

File tree

5 files changed

+24
-9
lines changed

5 files changed

+24
-9
lines changed

lib/fail.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,16 @@ export default async (pluginConfig, context) => {
2424
labels,
2525
assignee,
2626
retryLimit,
27+
retryStatusCodes,
2728
} = resolveConfig(pluginConfig, context);
2829
const { encodedProjectPath, projectApiUrl } = getProjectContext(context, gitlabUrl, gitlabApiUrl, repositoryUrl);
2930

3031
const apiOptions = {
3132
headers: { "PRIVATE-TOKEN": gitlabToken },
32-
retry: { limit: retryLimit },
33+
retry: {
34+
limit: retryLimit,
35+
statusCodes: retryStatusCodes,
36+
},
3337
};
3438

3539
if (failComment === false || failTitle === false) {

lib/publish.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ export default async (pluginConfig, context) => {
2222
nextRelease: { gitTag, gitHead, notes, version },
2323
logger,
2424
} = context;
25-
const { gitlabToken, gitlabUrl, gitlabApiUrl, assets, milestones, proxy, retryLimit } = resolveConfig(
26-
pluginConfig,
27-
context
28-
);
25+
const { gitlabToken, gitlabUrl, gitlabApiUrl, assets, milestones, proxy, retryLimit, retryStatusCodes } =
26+
resolveConfig(pluginConfig, context);
2927
const assetsList = [];
3028
const { projectPath, projectApiUrl } = getProjectContext(context, gitlabUrl, gitlabApiUrl, repositoryUrl);
3129

@@ -49,7 +47,7 @@ export default async (pluginConfig, context) => {
4947
},
5048
],
5149
},
52-
retry: { limit: retryLimit },
50+
retry: { limit: retryLimit, statusCodes: retryStatusCodes },
5351
};
5452

5553
debug("projectPath: %o", projectPath);

lib/resolve-config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ export default (
3636
}
3737
) => {
3838
const DEFAULT_RETRY_LIMIT = 3;
39+
// Added 422 to fix #839
40+
// https://github.com/sindresorhus/got/blob/a359bd385129d2adbc765b52dfbbadac5f54a825/documentation/7-retry.md#retry
41+
const DEFAULT_RETRY_STATUS_CODES = [408, 413, 422, 429, 500, 502, 503, 504, 521, 522, 524];
3942
const userGitlabApiPathPrefix = isNil(gitlabApiPathPrefix)
4043
? isNil(GL_PREFIX)
4144
? GITLAB_PREFIX
@@ -67,6 +70,7 @@ export default (
6770
labels: isNil(labels) ? "semantic-release" : labels === false ? false : labels,
6871
assignee,
6972
retryLimit: retryLimit ?? DEFAULT_RETRY_LIMIT,
73+
retryStatusCodes: DEFAULT_RETRY_STATUS_CODES,
7074
};
7175
};
7276

lib/success.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,20 @@ export default async (pluginConfig, context) => {
1515
commits,
1616
releases,
1717
} = context;
18-
const { gitlabToken, gitlabUrl, gitlabApiUrl, successComment, successCommentCondition, proxy, retryLimit } =
19-
resolveConfig(pluginConfig, context);
18+
const {
19+
gitlabToken,
20+
gitlabUrl,
21+
gitlabApiUrl,
22+
successComment,
23+
successCommentCondition,
24+
proxy,
25+
retryLimit,
26+
retryStatusCodes,
27+
} = resolveConfig(pluginConfig, context);
2028
const { projectApiUrl } = getProjectContext(context, gitlabUrl, gitlabApiUrl, repositoryUrl);
2129
const apiOptions = {
2230
headers: { "PRIVATE-TOKEN": gitlabToken },
23-
retry: { limit: retryLimit },
31+
retry: { limit: retryLimit, statusCodes: retryStatusCodes },
2432
};
2533

2634
if (successComment === false) {

test/resolve-config.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const defaultOptions = {
1818
assignee: undefined,
1919
proxy: {},
2020
retryLimit: 3,
21+
retryStatusCodes: [408, 413, 422, 429, 500, 502, 503, 504, 521, 522, 524],
2122
};
2223

2324
test("Returns user config", (t) => {

0 commit comments

Comments
 (0)