Unbounded Query

.findMany() / .select('*') with no limit

warningPerformanceno-unbounded-query

Why this matters

A query without a LIMIT returns every row in the table. As your data grows, this query gets slower, uses more memory, and eventually crashes your server or browser.

Example

Flaggedapp/api/users/route.ts
export async function GET() {
  // Returns ALL users — could be millions
  const users = await db.user.findMany();
  return Response.json(users);
}
Fixedapp/api/users/route.ts
export async function GET(req: Request) {
  const url = new URL(req.url);
  const page = parseInt(url.searchParams.get("page") ?? "1");
  const users = await db.user.findMany({
    take: 50,
    skip: (page - 1) * 50,
    orderBy: { createdAt: "desc" },
  });
  return Response.json(users);
}

How to fix

Add a LIMIT (take) and pagination to every query that returns a list. Default to a reasonable page size (20-100 items).

Reference

In the output
Findings carry "ruleId": "no-unbounded-query" in --json and the same id in SARIF and in the terminal.
Silence one line
// prodlint-disable-next-line no-unbounded-query
Silence a whole file
// prodlint-disable no-unbounded-query at the top of the file
How it works
Matches text patterns. Source on GitHub