MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / makeDbHandle

Function makeDbHandle

apps/cloud/src/mcp/session-durable-object.ts:129–148  ·  view source on GitHub ↗
(options: {
  readonly idleTimeout: number;
  readonly maxLifetime: number;
})

Source from the content-addressed store, hash-verified

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

Callers 2

makeEphemeralDbFunction · 0.85
openSessionDbMethod · 0.85

Calls 2

resolveConnectionStringFunction · 0.90
endMethod · 0.80

Tested by

no test coverage detected