Prevent D1 session reuse from stalling requests#103
Conversation
Scope D1 sessions to a single logical operation and stop reusing DB-backed service instances across unrelated Worker requests.
Greptile SummaryThis PR fixes a D1 read-replication stall bug where long-lived Key changes:
Session option propagation is handled correctly: Confidence Score: 5/5Safe to merge — the changes are logically correct, TypeScript-clean, and directly fix the documented D1 session-reuse stall. No P0 or P1 issues found. The withDbSession pattern is applied consistently across both services, session lifecycle (create → use → close in finally) is correct, first-primary pre-start is used wherever read-after-write consistency is required, and ServicePool correctly limits caching to non-DB services. No files require special attention. All three changed files look correct. Important Files Changed
Reviews (2): Last reviewed commit: "fix: verify account deletion without ban..." | Re-trigger Greptile |
Use a direct users existence check after delete so bans cannot mask a failed deletion.
Summary
Prevent long-lived D1 session state from leaking across unrelated requests and causing stalled responses while replicas catch up.
Changes Made
AirportServiceD1 sessions to a single logical operation and close them after useAuthServiceto use short-lived D1 sessions for bookmark-sensitive and write flowsServicePoolso request-specific D1 session state is not shared across Worker requestsAdditional Information
npx tsc --noEmitand targeted ESLint checks passed after these changes.Author Information
Discord Username: aussiescorcher
VATSIM CID: 1658308
Checklist: