Skip to content

Commit d8eca01

Browse files
authored
Merge branch 'dev' into clickhouse-sync-fixes
2 parents 21dc90a + 331dd5d commit d8eca01

4 files changed

Lines changed: 23 additions & 3 deletions

File tree

apps/backend/src/app/api/latest/integrations/stripe/webhooks/route.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ const subscriptionChangedEvents = [
4040
"payment_intent.canceled",
4141
] as const satisfies Stripe.Event.Type[];
4242

43+
const ignoredEvents = [
44+
"account.updated",
45+
"account.application.authorized",
46+
"capability.updated",
47+
"charge.failed",
48+
"balance.available",
49+
"customer.updated",
50+
] as const satisfies Stripe.Event.Type[];
51+
4352
const isSubscriptionChangedEvent = (event: Stripe.Event): event is Stripe.Event & { type: (typeof subscriptionChangedEvents)[number] } => {
4453
return subscriptionChangedEvents.includes(event.type as any);
4554
};
@@ -399,6 +408,10 @@ async function processStripeWebhookEvent(event: Stripe.Event): Promise<void> {
399408
});
400409
}
401410
}
411+
else if (typedIncludes(ignoredEvents, event.type)) {
412+
// These events are received but don't require processing
413+
return;
414+
}
402415
else {
403416
throw new StackAssertionError("Unknown stripe webhook type received: " + event.type, { event });
404417
}

apps/backend/src/app/api/latest/internal/external-db-sync/poller/route.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ export const GET = createSmartRouteHandler({
214214
await upstash.batchJSON(batchPayload);
215215
await deleteOutgoingRequests(requests.map((request) => request.id));
216216
processSpan.setAttribute("stack.external-db-sync.processed-count", requests.length);
217+
console.log(`[Poller] Processed requests: ${requests.length}`);
217218
return requests.length;
218219
} catch (error) {
219220
processSpan.setAttribute("stack.external-db-sync.iteration-error", true);

apps/backend/src/app/api/latest/internal/external-db-sync/sequencer/route.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ async function backfillSequenceIds(batchSize: number): Promise<boolean> {
137137
}
138138

139139
span.setAttribute("stack.external-db-sync.did-update", didUpdate);
140+
if (didUpdate) {
141+
console.log(`[Sequencer] Backfilled sequence IDs: USR=${projectUserTenants.length}, CC=${contactChannelTenants.length}, DR=${deletedRowTenants.length}`);
142+
}
140143

141144
return didUpdate;
142145
});
@@ -211,6 +214,7 @@ export const GET = createSmartRouteHandler({
211214
try {
212215
const didUpdate = await backfillSequenceIds(batchSize);
213216
iterationSpan.setAttribute("stack.external-db-sync.did-update", didUpdate);
217+
console.log(`[Sequencer] Backfilled ${didUpdate ? "some" : "no"} sequence IDs`);
214218
} catch (error) {
215219
iterationSpan.setAttribute("stack.external-db-sync.iteration-error", true);
216220
captureError(

apps/backend/src/route-handlers/smart-route-handler.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,18 @@ export function handleApiRequest(handler: (req: NextRequest, options: any, reque
105105
// request duration warning
106106
const allowedLongRequestPaths = [
107107
"/api/latest/internal/email-queue-step",
108-
"/api/v1/internal/analytics/query",
109108
"/api/latest/internal/analytics/query",
110109
"/health/email",
111-
"/api/v1/internal/metrics",
112110
"/api/latest/internal/metrics",
113111
"/api/latest/internal/external-db-sync/poller",
114112
"/api/latest/internal/external-db-sync/sequencer",
115113
"/api/latest/internal/external-db-sync/sync-engine",
116114
];
117-
const warnAfterSeconds = allowedLongRequestPaths.includes(req.nextUrl.pathname) ? 240 : 12;
115+
const allAllowedLongRequestPaths = [
116+
...allowedLongRequestPaths,
117+
...allowedLongRequestPaths.map(path => path.replace(/^\/api\/latest\//, "/api/v1/")),
118+
];
119+
const warnAfterSeconds = allAllowedLongRequestPaths.includes(req.nextUrl.pathname) ? 240 : 12;
118120
runAsynchronously(async () => {
119121
await wait(warnAfterSeconds * 1000);
120122
if (!hasRequestFinished) {

0 commit comments

Comments
 (0)