mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-06 12:57:46 +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,
|
||||
logLength: deploymentLogs?.length,
|
||||
});
|
||||
throw new Error(
|
||||
const error = new Error(
|
||||
`Expected deployment logs of ${deploymentId} to contain ${toCheck}, it was not found`
|
||||
);
|
||||
error.retries = 20;
|
||||
throw error;
|
||||
} else {
|
||||
logWithinTest('finished testing', JSON.stringify(probe));
|
||||
return;
|
||||
@@ -442,18 +444,19 @@ async function testDeployment(fixturePath, opts = {}) {
|
||||
try {
|
||||
await runProbe(probe, deploymentId, deploymentUrl, probeCtx);
|
||||
} catch (err) {
|
||||
if (!probe.retries) {
|
||||
const retries = Math.max(probe.retries || 0, err.retries || 0);
|
||||
if (!retries) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
for (let i = 0; i < probe.retries; i++) {
|
||||
logWithinTest(`re-trying ${i + 1}/${probe.retries}:`, stringifiedProbe);
|
||||
for (let i = 0; i < retries; i++) {
|
||||
logWithinTest(`re-trying ${i + 1}/${retries}:`, stringifiedProbe);
|
||||
|
||||
try {
|
||||
await runProbe(probe, deploymentId, deploymentUrl, probeCtx);
|
||||
break;
|
||||
} catch (err) {
|
||||
if (i === probe.retries - 1) {
|
||||
if (i === retries - 1) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user