fix(reconcile): connect mongoose before querying members
Some checks failed
Test / vitest (push) Successful in 10m59s
Test / playwright (push) Failing after 10m22s
Test / visual (push) Failing after 10m11s
Test / Notify on failure (push) Successful in 2s

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.
This commit is contained in:
Jennie Robinson Faber 2026-04-26 13:47:03 +01:00
parent 0369992cdd
commit a2a8d945c6

View file

@ -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 }