**TL;DR:** A sort or aggregation stage blew past the 100MB in-memory limit. The fix is an index on the sort, not just flipping allowDiskUse. Confirm Run the query with explain("executionStats"). Fix, in order 1.

## The fix

1. Index the sort: an index on the sort keys (matching sort direction) lets the query stream in order with no in-memory sort at all. This is the real fix.

2. Reduce the working set: push `$match` earlier, `$project` away unneeded fields before the heavy stage.

3. Only then consider `allowDiskUse: true` on the aggregation. It spills to disk and finishes, but slowly. Treat it as a bandage while the index builds, not the solution.

4. You are seeing this exact error message; match the block above, not just part of it.

5. The failing call matches the scenario in the title: Atlas error.

6. You want the fastest verified fix before digging through logs.

7. Your error text differs from the block above; close cousins often have different causes.

8. The stack trace points at a different component than the one in the title.

9. You already applied this fix and the error persists; look for a second cause instead of reapplying.

10. Not pinned to a specific version; follows current Atlas behavior.

## When to use this

- You are seeing this exact error message; match the block above, not just part of it.
- The failing call matches the scenario in the title: Atlas error.
- You want the fastest verified fix before digging through logs.

## When not to use this

- Your error text differs from the block above; close cousins often have different causes.
- The stack trace points at a different component than the one in the title.
- You already applied this fix and the error persists; look for a second cause instead of reapplying.