Skip to content

Commit

Permalink
refa: add what time for sync as a hotifx
Browse files Browse the repository at this point in the history
  • Loading branch information
sebald committed Nov 11, 2023
1 parent 6041d68 commit 9d0ae49
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app/api/sync/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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,
});
Expand Down

1 comment on commit 9d0ae49

@vercel
Copy link

@vercel vercel bot commented on 9d0ae49 Nov 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.