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

Function makeDbHandle

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

Source from the content-addressed store, hash-verified

119 * server can preserve session-local protocol state across requests.
120 */
121const 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
142const makeEphemeralDb = (): CloudSessionDbHandle =>
143 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