Category: Performance
Difficulty: Medium
Description
checkDatabase() in app.controller.ts:
private async checkDatabase(): Promise<ComponentHealth> {
try {
await this.prismaService.escrow.findMany({});
return { status: 'ok' };
} catch (err) {
findMany({}) with no where, no take and no select returns every escrow row. This runs on GET /health/ready and on the legacy GET /health, both of which a load balancer polls on a short interval.
#502 was filed for exactly this and is now closed, but the code on ac3b115 is unchanged. No merged pull request references it. Worth checking the others closed in the same batch before trusting their state.
Today the store is in memory so the cost is a full Map copy per probe. Once #475 lands and this is a real PrismaClient, it becomes an unbounded SELECT * against the escrow table on every health check.
Location
src/app.controller.ts
src/prisma/prisma.service.ts
Example commits
perf(health): probe the database with a bounded query
Acceptance Criteria
Technical Notes
findFirst({ select: { id: true } }) is the smallest change that keeps working through the in-memory store and a real client. A raw SELECT 1 is cheaper but will need the in-memory fake to support it.
Please reopen or reference #502 in the pull request so the closed-without-a-fix trail is visible.
Out of scope: the Horizon and Redis probes.
Before you start
- Set up with the steps in CONTRIBUTING.md. Node 22 is required (
.nvmrc), use npm ci rather than npm install, and export DATABASE_URL (or copy .env.example to .env) before npx prisma generate — prisma.config.ts reads it at load.
- Branch from
dev and open your pull request against dev. main is the released baseline.
- Tests needing an authenticated caller should use the
bearer() helper in test/auth-helper.ts, which mints a genuinely signed SEP-10 token. Never send a raw Stellar address, and never a placeholder, as a bearer token.
- You may cover more than one issue in a single pull request.
Join our community: https://t.me/+Y8K7AmrX9kViOTBk
Category: Performance
Difficulty: Medium
Description
checkDatabase()inapp.controller.ts:findMany({})with nowhere, notakeand noselectreturns every escrow row. This runs onGET /health/readyand on the legacyGET /health, both of which a load balancer polls on a short interval.#502 was filed for exactly this and is now closed, but the code on
ac3b115is unchanged. No merged pull request references it. Worth checking the others closed in the same batch before trusting their state.Today the store is in memory so the cost is a full
Mapcopy per probe. Once #475 lands and this is a realPrismaClient, it becomes an unboundedSELECT *against the escrow table on every health check.Location
src/app.controller.tssrc/prisma/prisma.service.tsExample commits
Acceptance Criteria
SELECT 1, acountwith a limit, or afindFirstwithselect: { id: true }are all acceptable.downwhen the database is unreachable./health/readyis unchanged.downon a thrown error andokotherwise, and that it does not callfindMany.Technical Notes
findFirst({ select: { id: true } })is the smallest change that keeps working through the in-memory store and a real client. A rawSELECT 1is cheaper but will need the in-memory fake to support it.Please reopen or reference #502 in the pull request so the closed-without-a-fix trail is visible.
Out of scope: the Horizon and Redis probes.
Before you start
.nvmrc), usenpm cirather thannpm install, and exportDATABASE_URL(or copy.env.exampleto.env) beforenpx prisma generate—prisma.config.tsreads it at load.devand open your pull request againstdev.mainis the released baseline.bearer()helper intest/auth-helper.ts, which mints a genuinely signed SEP-10 token. Never send a raw Stellar address, and never a placeholder, as a bearer token.Join our community: https://t.me/+Y8K7AmrX9kViOTBk