Skip to content

Commit 11d0204

Browse files
committed
fix(indexer): handle insertion error when cast has no url embeds
1 parent 00993e0 commit 11d0204

File tree

3 files changed

+29
-19
lines changed

3 files changed

+29
-19
lines changed

.changeset/real-dogs-end.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"metadata-indexer": patch
3+
---
4+
5+
fix: handle insertion error when cast has no url embeds

examples/metadata-indexer/src/hubReplicator.ts

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -288,20 +288,30 @@ export class HubReplicator {
288288
index,
289289
}));
290290

291-
await this.db
292-
.insertInto("castEmbedUrls")
293-
.values(
294-
urls.map(({ url, normalizedUrl, index }) => {
295-
return {
296-
castHash: castRow.hash,
297-
url: normalizedUrl, // Null values filtered above
298-
unnormalizedUrl: url,
299-
index,
300-
};
301-
})
302-
)
303-
.onConflict((oc) => oc.doNothing())
304-
.execute();
291+
if (urls.length === 0) {
292+
continue;
293+
}
294+
295+
const query = this.db.insertInto("castEmbedUrls").values(
296+
urls.map(({ url, normalizedUrl, index }) => {
297+
return {
298+
castHash: castRow.hash,
299+
url: normalizedUrl,
300+
unnormalizedUrl: url,
301+
index,
302+
};
303+
})
304+
);
305+
306+
try {
307+
await query.onConflict((oc) => oc.doNothing()).execute();
308+
} catch (error) {
309+
this.log.error(
310+
`There was a problem processing cast with hash ${castRow.hash.toString()}`
311+
);
312+
this.log.error(error);
313+
this.log.error(query.compile().sql);
314+
}
305315

306316
// this.log.info(
307317
// `[Sync] Indexed ${urls.length} URLs from cast ${bytesToHex(

examples/metadata-indexer/src/indexerQueue.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,6 @@ export class IndexerQueue {
9494
this.log.error(
9595
`[URL Indexer] Response not ok [${response.status}] ${queryUrl}`
9696
);
97-
if (response.status === 400 && retries === 0) {
98-
// Retry 400 errors
99-
this.log.info(`[URL Indexer] Queueing retry for ${url}...`);
100-
this.indexQueue.push({ url, retries: retries + 1 });
101-
}
10297
return;
10398
}
10499

0 commit comments

Comments
 (0)