(options: {
readonly idleTimeout: number;
readonly maxLifetime: number;
})
| 119 | * server can preserve session-local protocol state across requests. |
| 120 | */ |
| 121 | const makeDbHandle = (options: { |
| 122 | readonly idleTimeout: number; |
| 123 | readonly maxLifetime: number; |
| 124 | }): CloudSessionDbHandle => { |
| 125 | const sql = postgres(resolveConnectionString(), { |
| 126 | max: 1, |
| 127 | idle_timeout: options.idleTimeout, |
| 128 | max_lifetime: options.maxLifetime, |
| 129 | connect_timeout: 10, |
| 130 | fetch_types: false, |
| 131 | prepare: true, |
| 132 | onnotice: () => undefined, |
| 133 | }); |
| 134 | return { |
| 135 | sql, |
| 136 | db: drizzle(sql, { schema: combinedSchema }) as DrizzleDb, |
| 137 | // oxlint-disable-next-line executor/no-promise-catch -- boundary: postgres.js close is best-effort during DO/runtime cleanup |
| 138 | end: () => sql.end({ timeout: 0 }).catch(() => undefined), |
| 139 | }; |
| 140 | }; |
| 141 | |
| 142 | const makeEphemeralDb = (): CloudSessionDbHandle => |
| 143 | makeDbHandle({ idleTimeout: 0, maxLifetime: 60 }); |
no test coverage detected