Skip to content

Commit be510be

Browse files
eabdelmoneimclaude
andcommitted
fix: treat backfill entry as authoritative in get-logs endpoint
When a backfill entry exists (even if errored), skip the Redis lookup entirely. Previously an errored backfill entry would fall through to Redis, potentially returning stale data for an orphaned transaction. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent fc367a5 commit be510be

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,20 @@ export async function getTransactionLogs(fastify: FastifyInstance) {
160160
// queue IDs that are stuck in Redis (e.g. orphaned "queued" transactions).
161161
if (env.ENABLE_TX_BACKFILL_FALLBACK) {
162162
const backfill = await TransactionDB.getBackfill(queueId);
163-
if (backfill?.status === "mined" && backfill.transactionHash && isHex(backfill.transactionHash)) {
164-
hash = backfill.transactionHash as Hex;
163+
if (backfill) {
164+
// Backfill entry exists and is authoritative — only set hash if mined.
165+
// If backfill is errored, hash stays undefined and we skip Redis lookup.
166+
if (backfill.status === "mined" && backfill.transactionHash && isHex(backfill.transactionHash)) {
167+
hash = backfill.transactionHash as Hex;
168+
}
169+
} else {
170+
// No backfill entry — fall back to Redis.
171+
const transaction = await TransactionDB.get(queueId);
172+
if (transaction?.status === "mined") {
173+
hash = transaction.transactionHash;
174+
}
165175
}
166-
}
167-
168-
if (!hash) {
176+
} else {
169177
const transaction = await TransactionDB.get(queueId);
170178
if (transaction?.status === "mined") {
171179
hash = transaction.transactionHash;

0 commit comments

Comments
 (0)