Skip to content

Commit fc367a5

Browse files
eabdelmoneimclaude
andcommitted
fix: check backfill before Redis in get-logs endpoint too
Same change as status endpoint — backfill entries should take priority over stale Redis data for consistency across all endpoints. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 24064f1 commit fc367a5

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

src/server/routes/transaction/blockchain/get-logs.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -155,23 +155,22 @@ export async function getTransactionLogs(fastify: FastifyInstance) {
155155
// Get the transaction hash from the provided input.
156156
let hash: Hex | undefined;
157157
if (queueId) {
158-
// Primary lookup
159-
const transaction = await TransactionDB.get(queueId);
160-
if (transaction?.status === "mined") {
161-
hash = transaction.transactionHash;
162-
}
163-
164158
// SPECIAL LOGIC FOR AMEX
165-
// AMEX uses this endpoint to get logs for transactions they didn't receive webhooks for
166-
// the queue ID's were cleaned out of REDIS so we backfilled tx hashes to this backfill table
167-
// see https://github.com/thirdweb-dev/solutions-customer-scripts/blob/main/amex/scripts/load-backfill-via-api.ts
168-
// Fallback to backfill table if enabled and not found
169-
if (!hash && env.ENABLE_TX_BACKFILL_FALLBACK) {
159+
// Backfill table takes priority — entries are intentional overrides for
160+
// queue IDs that are stuck in Redis (e.g. orphaned "queued" transactions).
161+
if (env.ENABLE_TX_BACKFILL_FALLBACK) {
170162
const backfill = await TransactionDB.getBackfill(queueId);
171163
if (backfill?.status === "mined" && backfill.transactionHash && isHex(backfill.transactionHash)) {
172164
hash = backfill.transactionHash as Hex;
173165
}
174166
}
167+
168+
if (!hash) {
169+
const transaction = await TransactionDB.get(queueId);
170+
if (transaction?.status === "mined") {
171+
hash = transaction.transactionHash;
172+
}
173+
}
175174
} else if (transactionHash) {
176175
hash = transactionHash as Hex;
177176
}

0 commit comments

Comments
 (0)