method

bun.SQL.close

options?: { timeout: number }
): Promise<void>;

Closes every connection of the pool. With timeout: 0 it closes immediately; with no timeout it waits for all queries to finish first.

It waits for the queries that started before the call. When the timeout ends, the queries that still run reject with ERR_POSTGRES_CONNECTION_CLOSED or ERR_MYSQL_CONNECTION_CLOSED, and so does everything that is started after close().

You can call it again. Every call resolves when the pool is closed, and the shortest timeout counts.

@param options

Optional timeout in seconds, an upper bound for the wait

await sql.close({ timeout: 1 });