Yield bounded catch-up batches behind per-user readiness queues

This commit is contained in:
syntaxbullet
2026-09-08 16:18:09 +02:00
parent 30dee55799
commit 31e4f3b2ef
4 changed files with 80 additions and 11 deletions

View File

@@ -41,8 +41,9 @@ export function createHabitRoutes(db: AppDatabase, auth: ReturnType<typeof creat
try { payload.value = await c.req.json(); } catch { payload.malformed = true; }
}
c.set('payload', payload);
const service = new HabitService(db, c.get('user'), now());
service.sync(); c.set('service', service); await next();
await HabitService.withPrepared(db, c.get('user'), now, async service => {
c.set('service', service); await next();
});
}); if (response) c.res = response; };
if (!['GET', 'HEAD', 'OPTIONS'].includes(c.req.method)) {
const response = await origin(c, proceed); if (response) c.res = response;