Skip to content

Commit

Permalink
feat: only retry if block out of range
Browse files Browse the repository at this point in the history
  • Loading branch information
yonadaa committed Apr 23, 2024
1 parent a6ce365 commit ade6164
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/cli/src/deploy/getResourceIds.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Client, parseAbiItem, Hex } from "viem";
import { Client, parseAbiItem, Hex, HttpRequestError } from "viem";
import { getLogs } from "viem/actions";
import { storeSpliceStaticDataEvent } from "@latticexyz/store";
import { WorldDeploy, storeTables } from "./common";
Expand Down Expand Up @@ -28,6 +28,16 @@ export async function getResourceIds({
}),
{
retries: 3,
onFailedAttempt: async (error) => {
const shouldRetry =
error instanceof HttpRequestError &&
error.status === 400 &&
error.message.includes('"block is out of range"');

if (!shouldRetry) {
throw error;
}
},
},
);
const resourceIds = logs.map((log) => log.args.keyTuple[0]);
Expand Down

0 comments on commit ade6164

Please sign in to comment.