From 9d0ae49748819f3d5154f5f045db11d154e4e352 Mon Sep 17 00:00:00 2001 From: Sebastian Sebald Date: Sat, 11 Nov 2023 22:59:14 +0100 Subject: [PATCH] refa: add what time for sync as a hotifx --- app/api/sync/route.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/api/sync/route.ts b/app/api/sync/route.ts index b2e44cf5..86b6d51b 100644 --- a/app/api/sync/route.ts +++ b/app/api/sync/route.ts @@ -2,6 +2,16 @@ import { NextRequest, NextResponse } from 'next/server'; import { getLastSync } from '@/lib/db/system'; import { sync } from '@/lib/db/sync'; +/** + * For whatever reasons the async tasks (db requests) + * dont wait until the whole thing is really finished. + * Hotfix to just wait a bit ... bad, but whatever until + * we know why this is happening. + */ +const delay = (ms: number) => { + return new Promise(resolve => setTimeout(resolve, ms)); +}; + // POST // --------------- export const POST = async (request: NextRequest) => { @@ -22,6 +32,9 @@ export const POST = async (request: NextRequest) => { const msg = await sync(lastSync); + // Let's hope 5 seconds is enought to add new squads... + await delay(5000); + return NextResponse.json(msg, { status: 200, });