mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-09 04:22:07 +00:00
some errors can specify retries (#11581)
Trying a different approach to retrying errors when logs must contain a value. Alternative to: https://github.com/vercel/vercel/pull/11577
This commit is contained in:
5
.changeset/plenty-plants-dream.md
Normal file
5
.changeset/plenty-plants-dream.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
some errors can specify retries
|
||||||
@@ -122,9 +122,11 @@ async function runProbe(probe, deploymentId, deploymentUrl, ctx) {
|
|||||||
deploymentLogs,
|
deploymentLogs,
|
||||||
logLength: deploymentLogs?.length,
|
logLength: deploymentLogs?.length,
|
||||||
});
|
});
|
||||||
throw new Error(
|
const error = new Error(
|
||||||
`Expected deployment logs of ${deploymentId} to contain ${toCheck}, it was not found`
|
`Expected deployment logs of ${deploymentId} to contain ${toCheck}, it was not found`
|
||||||
);
|
);
|
||||||
|
error.retries = 20;
|
||||||
|
throw error;
|
||||||
} else {
|
} else {
|
||||||
logWithinTest('finished testing', JSON.stringify(probe));
|
logWithinTest('finished testing', JSON.stringify(probe));
|
||||||
return;
|
return;
|
||||||
@@ -442,18 +444,19 @@ async function testDeployment(fixturePath, opts = {}) {
|
|||||||
try {
|
try {
|
||||||
await runProbe(probe, deploymentId, deploymentUrl, probeCtx);
|
await runProbe(probe, deploymentId, deploymentUrl, probeCtx);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (!probe.retries) {
|
const retries = Math.max(probe.retries || 0, err.retries || 0);
|
||||||
|
if (!retries) {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < probe.retries; i++) {
|
for (let i = 0; i < retries; i++) {
|
||||||
logWithinTest(`re-trying ${i + 1}/${probe.retries}:`, stringifiedProbe);
|
logWithinTest(`re-trying ${i + 1}/${retries}:`, stringifiedProbe);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await runProbe(probe, deploymentId, deploymentUrl, probeCtx);
|
await runProbe(probe, deploymentId, deploymentUrl, probeCtx);
|
||||||
break;
|
break;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (i === probe.retries - 1) {
|
if (i === retries - 1) {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user