diff --git a/app/[locale]/layout.tsx b/app/[locale]/layout.tsx index d360aaa3..b2f0b050 100644 --- a/app/[locale]/layout.tsx +++ b/app/[locale]/layout.tsx @@ -88,7 +88,10 @@ export default async function Layout(props: { }); } - serverServices.analytics.trackPageview(); + const { after } = await import('next/server'); + after(() => { + serverServices.analytics.trackPageview(); + }); } catch { if (process.env.NODE_ENV !== 'production' || !process.env.CI) { console.warn( diff --git a/lib/services/analytics/umami-analytics-service.ts b/lib/services/analytics/umami-analytics-service.ts index cf70c6d0..edea6182 100644 --- a/lib/services/analytics/umami-analytics-service.ts +++ b/lib/services/analytics/umami-analytics-service.ts @@ -91,7 +91,7 @@ export class UmamiAnalyticsService implements AnalyticsService { // Add a timeout to prevent hanging requests const controller = new AbortController(); - const timeoutId = setTimeout(() => controller.abort(), 10000); // 10s timeout + const timeoutId = setTimeout(() => controller.abort(), 2000); // 2s timeout const headers: Record = { 'Content-Type': 'application/json', diff --git a/lib/services/notifications/gotify-notification-service.ts b/lib/services/notifications/gotify-notification-service.ts index d18bfa04..351396e0 100644 --- a/lib/services/notifications/gotify-notification-service.ts +++ b/lib/services/notifications/gotify-notification-service.ts @@ -17,6 +17,9 @@ export class GotifyNotificationService implements NotificationService { const url = new URL('message', this.config.url); url.searchParams.set('token', this.config.token); + const controller = new AbortController(); + const timeoutId = setTimeout(() => controller.abort(), 5000); + const response = await fetch(url.toString(), { method: 'POST', headers: { @@ -27,8 +30,11 @@ export class GotifyNotificationService implements NotificationService { message, priority, }), + signal: controller.signal, }); + clearTimeout(timeoutId); + if (!response.ok) { const errorText = await response.text(); console.error('Gotify notification failed:', {