ReviewOS

stacks/bun-query-builder

Slow-query threshold + populate 'params' in query hooks

#1045
Closed glennmichael123 opened this 22 days ago · 0 comments
22 days ago

Summary

QueryHooks + runWithHooks already measure durationMs and fire onQueryStart/onQueryEnd. Two gaps: (a) the params field declared on every hook event is never populated — hooks receive only { sql, kind }, so consumers can't log bound values; (b) no built-in slow-query warning.

Proposal

  • Populate params on the hook events.
  • Add config.hooks.slowQueryThresholdMs (or onSlowQuery) that fires when durationMs exceeds it, reusing the existing timing.

This is also the closest feasible proxy for the connection-leak detection deferred in #1014 (Bun's pool exposes no checkout hooks).

Effort: S. Location: src/client.ts runWithHooks (~2364), src/types.ts QueryHooks (~203). Found via internal code audit.

Sign in to comment on this issue.