From a2a8d945c6d45ee39029db965a732732ffcb1e97 Mon Sep 17 00:00:00 2001 From: Jennie Robinson Faber Date: Sun, 26 Apr 2026 13:47:03 +0100 Subject: [PATCH] fix(reconcile): connect mongoose before querying members MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Route was the only DB-using endpoint that didn't call connectDB(); other routes warm the connection incidentally, but on a freshly-booted container with no SLACK_BOT_TOKEN the slack-joins plugin skips and nothing else opens the pool — first reconcile request hung 10s on buffered Member.find() and returned 500. --- server/api/internal/reconcile-payments.post.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/api/internal/reconcile-payments.post.js b/server/api/internal/reconcile-payments.post.js index 762ba40..9c0686f 100644 --- a/server/api/internal/reconcile-payments.post.js +++ b/server/api/internal/reconcile-payments.post.js @@ -9,6 +9,7 @@ import Member from '../../models/member.js' import Payment from '../../models/payment.js' import { listHelcimCustomerTransactions } from '../../utils/helcim.js' +import { connectDB } from '../../utils/mongoose.js' import { upsertPaymentFromHelcim } from '../../utils/payments.js' // Same filter upsertPaymentFromHelcim applies — keep dry-run summary in sync. @@ -51,6 +52,8 @@ export default defineEventHandler(async (event) => { const apply = getQuery(event).apply !== 'false' + await connectDB() + const members = await Member.find( { helcimCustomerId: { $exists: true, $ne: null } }, { _id: 1, email: 1, name: 1, helcimCustomerId: 1, helcimSubscriptionId: 1, billingCadence: 1 }