Skip to content

traceperf test, run --routes, MySQL index check, ORM-specific N+1 fixes - #28

Merged
thelastbackspace merged 1 commit into
mainfrom
feat/test-and-routes
Nov 17, 2026
Merged

thelastbackspace merged 1 commit into
mainfrom
feat/test-and-routes

Conversation

@thelastbackspace

Copy link
Copy Markdown
Owner

What

  • traceperf test -- <test command>: counts the database and HTTP calls each route makes per request during the app's own tests (supertest, or fetch to a server the tests start). No routes to list, no synthetic load. Supports Jest (a hook into jest-runtime tracks drivers loaded into its per-file sandboxes), Vitest, Mocha and node:test. Baselines, --markdown and --json work as they do for run; the tests' own exit code wins. The action takes test: npm test in place of run.
  • run --routes / --param id=1: finds GET routes in Express 4 and 5 (nested routers included; Express 5 mount paths are recorded as routers are mounted) and Fastify (onRoute).
  • Missing-index check on MySQL and MariaDB via EXPLAIN FORMAT=JSON. The index is named (MySQL requires an index name). Selectivity uses rows examined, because MySQL's default estimate for col = value is exactly 10%.
  • N+1 fixes in the app's own ORM (read from package.json): Sequelize, TypeORM, MikroORM, Drizzle, Objection, Kysely, Knex, Bookshelf, Mongoose, Prisma, plus Redis.
  • node-redis 4 legacyMode clients are now tracked.

Bug found

mysql2 3.10–3.11 didn't track queries on pooled connections at all. In those versions PoolConnection extends BaseConnection, not Connection. The fix patches the prototype that defines each method. The new mysql2@3.11 compat check fails before the fix and passes after.

Tests

  • Unit: routes, test mode (including an end-to-end test with a child process and a fake jest-runtime), MySQL plans, ORM advice, mysql2 class layout, and node-redis legacy clients (real redis 4 and 5 against a local RESP server). 320 tests pass; coverage is above the gates.
  • Compat: Prisma 7, mysql2 3.11, node-redis callback clients, and EXPLAIN on MySQL 8.4 and MariaDB 11.
  • Action self-test: traceperf test passes on the batched example and catches the planted N+1.
  • Checked by hand: Jest and Vitest with supertest + pg, --routes on Express 4, Express 5 and Fastify, and the MySQL index check on a 20k-row table.

https://claude.ai/code/session_018DeDdh4rUnNHJ7wcJrP51T

- traceperf test -- <cmd>: count calls per route during the app's own tests
  (Jest sandboxes included, Vitest, Mocha, node:test); baseline, markdown,
  JSON; the action takes test: in place of run
- run --routes / --param: find Express 4/5 and Fastify GET routes
- missing-index check on MySQL / MariaDB via EXPLAIN FORMAT=JSON
- N+1 advice names the call in the ORM from package.json
- node-redis 4 legacyMode clients tracked
- fix: mysql2 3.10-3.11 pooled queries were not tracked
- compat: Prisma 7, mysql2 3.11, redis callback clients, EXPLAIN on MySQL 8.4 and MariaDB 11
@thelastbackspace
thelastbackspace merged commit ed3cf78 into main Nov 17, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant