From 5d590ca5b1f9901049dd43905035f901a00ba891 Mon Sep 17 00:00:00 2001 From: jubnl Date: Tue, 22 Sep 2026 00:04:19 +0200 Subject: [PATCH] chore(server): db-call-graph --sync stops its transitive walk at an async callee --- server/scripts/db-call-graph.mjs | 15 ++++++++++++--- server/src/nest/place-shadow/place-shadow.job.ts | 5 +---- server/src/nest/route-usage/route-usage.job.ts | 5 +---- server/src/nest/storage/storage-usage-scan.job.ts | 5 +---- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/server/scripts/db-call-graph.mjs b/server/scripts/db-call-graph.mjs index 2742420e2..35d5948c4 100644 --- a/server/scripts/db-call-graph.mjs +++ b/server/scripts/db-call-graph.mjs @@ -6,9 +6,15 @@ * --sync every *synchronous* method under `server/src/**` that touches the * database — directly (a `get/all/run/prepare/transaction/exec/pragma` * or a `canAccessTrip/isOwner/rosterUserIds/getPlaceWithTags` call on a - * DatabaseService / raw handle) or transitively (it calls, through - * `this.*`, a method that does). These are exactly the methods the - * sweep's R1 turns into `async` ones. + * DatabaseService / raw handle) or transitively through a chain of + * *synchronous* `this.*` calls that does. An `async` callee is a + * stopping point for this walk: it is not traversed into, and its own + * DB reach (direct or transitive) is not attributed to the caller — so + * a sync method that only calls already-async methods (e.g. an + * `onApplicationBootstrap()` hook that schedules an async cron + * callback) is not listed here. That shape is `--unawaited`'s job, not + * `--sync`'s. These are exactly the methods the sweep's R1 turns into + * `async` ones. * --tx every real `…​.transaction(` call site (the AST sees calls, so the six * prose mentions inside doc comments that `grep` finds are not here). * These are the sites R2 routes through `UnitOfWork.transactional`. @@ -465,6 +471,9 @@ for (const c of allClasses) { seen.add(k); const t = methodIndex.get(k); if (!t) continue; + // An async callee stops the walk: neither its own DB reach nor anything further + // behind it is attributed to the (sync) caller — that's --unawaited's job. See header. + if (t.m.async) continue; if (t.m.directDb) dbCallees.add(k); for (const nk of calleeKeys(t.cls, t.m)) if (!seen.has(nk)) stack.push(nk); } diff --git a/server/src/nest/place-shadow/place-shadow.job.ts b/server/src/nest/place-shadow/place-shadow.job.ts index 96d937f3e..3b84f4bbc 100644 --- a/server/src/nest/place-shadow/place-shadow.job.ts +++ b/server/src/nest/place-shadow/place-shadow.job.ts @@ -19,10 +19,7 @@ export class PlaceShadowRetentionJob implements OnApplicationBootstrap { private readonly registrar: CronRegistrarService, ) {} - // `async` only so the sweep's call-graph gate sees a non-sync DB-reaching - // frame here: nothing in the body awaits, and Nest awaits the returned - // promise before the next bootstrap hook, exactly as it did the `void`. - async onApplicationBootstrap(): Promise { + onApplicationBootstrap(): void { if (!this.registrar.isEnabled()) return; this.registrar.register('place-shadow-retention', '40 3 * * *', () => this.tick()); } diff --git a/server/src/nest/route-usage/route-usage.job.ts b/server/src/nest/route-usage/route-usage.job.ts index 8d2260e48..bfc6c2787 100644 --- a/server/src/nest/route-usage/route-usage.job.ts +++ b/server/src/nest/route-usage/route-usage.job.ts @@ -20,10 +20,7 @@ export class RouteUsageRetentionJob implements OnApplicationBootstrap { private readonly registrar: CronRegistrarService, ) {} - // `async` only so the sweep's call-graph gate sees a non-sync DB-reaching - // frame here: nothing in the body awaits, and Nest awaits the returned - // promise before the next bootstrap hook, exactly as it did the `void`. - async onApplicationBootstrap(): Promise { + onApplicationBootstrap(): void { if (!this.registrar.isEnabled()) return; this.registrar.register('route-usage-retention', '45 3 * * *', () => this.tick()); } diff --git a/server/src/nest/storage/storage-usage-scan.job.ts b/server/src/nest/storage/storage-usage-scan.job.ts index 0215fd5f3..956a6ce52 100644 --- a/server/src/nest/storage/storage-usage-scan.job.ts +++ b/server/src/nest/storage/storage-usage-scan.job.ts @@ -12,10 +12,7 @@ export class StorageUsageScanJob implements OnApplicationBootstrap { private readonly stats: StorageStatsService, ) {} - // `async` only so the sweep's call-graph gate sees a non-sync DB-reaching - // frame here: nothing in the body awaits, and Nest awaits the returned - // promise before the next bootstrap hook, exactly as it did the `void`. - async onApplicationBootstrap(): Promise { + onApplicationBootstrap(): void { if (!this.registrar.isEnabled()) return; this.registrar.register('storage-usage-scan', '15 4 * * *', () => { void this.tick();