| 1604 | * loop. |
| 1605 | */ |
| 1606 | const retryStale = ( |
| 1607 | plan: Plan, |
| 1608 | cache: PreparedCache, |
| 1609 | run: Effect.Effect<QueryOutput, SqlError>, |
| 1610 | rerun: () => Effect.Effect<QueryOutput, SqlError> |
| 1611 | ): Effect.Effect<QueryOutput, SqlError> => |
| 1612 | Effect.catchCause(run, (cause) => { |
| 1613 | if (!plan.stale) return Effect.failCause(cause) |
| 1614 | cache.evict(plan.prepared!) |
| 1615 | return rerun() |
| 1616 | }) |
| 1617 | |
| 1618 | const connectionQueryError = (cause: unknown, message: string): SqlError => |
| 1619 | new SqlError({ reason: new ConnectionError({ cause, message, operation: "query" }) }) |