Hanging timeout server-side requests using Cloudflare Hyperdrive

Anyone have success using Cloudflare Hyperdrive with Better-Auth?

Basically, I have sign-in functionality server-side like:
    const result = await auth(env).api.signInEmail({
      body: {
        email,
        password,
      },
      asResponse: true,
    });

But it's hanging forever when I hit it. No logs, just forever loading.

Auth looks like:
  export const auth = (env: Env) =>
    betterAuth({
      database: {
        dialect: new PostgresJSDialect({
          postgres: getDb(env), // Call getDb() as a function to create a new connection each time
        }),
        // dialect,
        type: "postgres",
      },
      emailAndPassword: {
        // email and password stuff
      },
      secret: BETTER_AUTH_SECRET,
    });

And getDb function looks like:
export function getDb(env: Env) {
  // Connection URL from environment variables
  let connectionString = env.HYPERDRIVE.connectionString;

  const sql = postgres(connectionString, {
    max: 5,
    // idle_timeout: 30,
    ssl: import.meta.env.DEV,
    // Debug options - remove in production
    debug: true,
    fetch_types: false,
  });

  return sql;
}

If I use the postgres connectionString directly, it works. But if I use the Hyperdrive connectionString, it hangs.

Any ideas?
Was this page helpful?