Does ctx.waitUntil work with hyperdrive?

Hello I have the following worker that listens for notifications from a service.
export default {
  async fetch(
    request: Request,
    env: Env,
    ctx: ExecutionContext,
  ): Promise<Response> {
    if (request.method !== "POST") {
      return new Response(null, {
        status: 405,
        statusText: "Method Not Allowed",
      });
    }

    const userAgent = request.headers.get("user-agent");
    const data = await request.json();
    const connectionString = env.staging.connectionString;

    console.log(userAgent, data, connectionString);

    if (userAgent?.includes("<example>")) {
      console.log("correct agent")

      const sql = postgres(connectionString, { prepare: false });
      ctx.waitUntil(sql`INSERT INTO payment_logs(user_id) VALUES (999);`);

      return new Response(undefined, { status: 200 });
    }

    return new Response(undefined, { status: 405 });
  },
};


The service disconnects immediately on making the connection and delivering the notification and ctx.waitUntil is not functioning and the database is never updated. Is this a problem with using hyperdrive here? Am I doing something else wrong?

When I test this api endpoint from my machine it works but I do not disconnect immediately like the service
Was this page helpful?