Ramtin
Ramtin
CDCloudflare Developers
Created by Ramtin on 4/19/2025 in #hyperdrive
Hi all,
I DMed you.
9 replies
CDCloudflare Developers
Created by Ramtin on 4/19/2025 in #hyperdrive
Hi all,
Sometimes my SQL queries fail randomly and I get the following error:
PostgresError: Protocol Error: First response to flushed describe was not a ParseComplete.
PostgresError: Protocol Error: First response to flushed describe was not a ParseComplete.
I thought it might be due to not closing the Hyperdrive connection correctly or its configurations but I think it might be a problem with Hyperdrive itself
9 replies
CDCloudflare Developers
Created by Ramtin on 4/19/2025 in #hyperdrive
Hi all,
Thank you for your response. Would you recommend closing the SQL connections manually after each request as well? Also could you please advise whether the following configuration for establishing SQL connections to Hyperdrive is appropriate to use across the worker? I’ve seen some examples where max is set to 1 instead of 5.
export function getSql(env: Env) {
return postgres(env.HYPERDRIVE.connectionString, {
max: 5, // Use a small pool to reduce overhead
idle_timeout: 5, // Quickly close idle connections
connect_timeout: 5, // Fail fast if connection can't be established
max_lifetime: 60, // Limit connection lifetime to 1 minute
onnotice: () => {}, // Suppress server notices
onparameter: () => {}, // Suppress parameter change logs
debug: (connection, query, parameters) => {
console.log(`[SQL] ${query}`, parameters)
}
})
}
export function getSql(env: Env) {
return postgres(env.HYPERDRIVE.connectionString, {
max: 5, // Use a small pool to reduce overhead
idle_timeout: 5, // Quickly close idle connections
connect_timeout: 5, // Fail fast if connection can't be established
max_lifetime: 60, // Limit connection lifetime to 1 minute
onnotice: () => {}, // Suppress server notices
onparameter: () => {}, // Suppress parameter change logs
debug: (connection, query, parameters) => {
console.log(`[SQL] ${query}`, parameters)
}
})
}
9 replies