(options: {
readonly idleTimeout: number;
readonly maxLifetime: number;
})
| 147 | * server can preserve session-local protocol state across requests. |
| 148 | */ |
| 149 | const makeDbHandle = (options: { |
| 150 | readonly idleTimeout: number; |
| 151 | readonly maxLifetime: number; |
| 152 | }): CloudSessionDbHandle => { |
| 153 | const sql = postgres(resolveConnectionString(), { |
| 154 | max: 1, |
| 155 | idle_timeout: options.idleTimeout, |
| 156 | max_lifetime: options.maxLifetime, |
| 157 | connect_timeout: 10, |
| 158 | fetch_types: false, |
| 159 | prepare: true, |
| 160 | onnotice: () => undefined, |
| 161 | }); |
| 162 | return { |
| 163 | sql, |
| 164 | db: drizzle(sql, { schema: combinedSchema }) as DrizzleDb, |
| 165 | // oxlint-disable-next-line executor/no-promise-catch -- boundary: postgres.js close is best-effort during DO/runtime cleanup |
| 166 | end: () => sql.end({ timeout: 0 }).catch(() => undefined), |
| 167 | }; |
| 168 | }; |
| 169 | |
| 170 | const makeEphemeralDb = (): CloudSessionDbHandle => |
| 171 | makeDbHandle({ idleTimeout: 0, maxLifetime: 60 }); |
no test coverage detected