| 123 | * runaway backlog from materializing unboundedly into memory each run. |
| 124 | */ |
| 125 | export async function findDeadLetteredEvents( |
| 126 | eventTypes: string[] |
| 127 | ): Promise<(typeof outboxEvent.$inferSelect)[]> { |
| 128 | if (eventTypes.length === 0) return [] |
| 129 | return db |
| 130 | .select() |
| 131 | .from(outboxEvent) |
| 132 | .where(and(eq(outboxEvent.status, 'dead_letter'), inArray(outboxEvent.eventType, eventTypes))) |
| 133 | .limit(DEAD_LETTER_SCAN_LIMIT) |
| 134 | } |
| 135 | |
| 136 | /** |
| 137 | * True when an event of the given type whose JSON payload has |