MCPcopy Create free account
hub / github.com/Effect-TS/effect / retryStale

Function retryStale

packages/sql/pg/src/PgConnection.ts:1606–1616  ·  view source on GitHub ↗
(
  plan: Plan,
  cache: PreparedCache,
  run: Effect.Effect<QueryOutput, SqlError>,
  rerun: () => Effect.Effect<QueryOutput, SqlError>
)

Source from the content-addressed store, hash-verified

1604 * loop.
1605 */
1606const 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
1618const connectionQueryError = (cause: unknown, message: string): SqlError =>
1619 new SqlError({ reason: new ConnectionError({ cause, message, operation: "query" }) })

Callers 1

PgConnectionImplClass · 0.85

Calls 1

evictMethod · 0.80

Tested by

no test coverage detected