method

bun.SQL.Query.cancel

cancel(): Query<T>;

Cancels the query.

A query that Bun has not sent yet never runs. It rejects with ERR_POSTGRES_QUERY_CANCELLED (or the MYSQL / SQLITE code).

PostgreSQL: Bun asks the server to stop a running query, on a second connection. The query rejects with the server's error, errno "57014", or resolves if it ends first. A query that Bun sent behind another one, or that has another one sent behind it, rejects with ERR_POSTGRES_QUERY_CANCELLED and a hint, because the server may still run it.

MySQL: a query that Bun has sent runs to the end and settles with its result.