fix(mindspace): use lightweight page sync for background list refresh
Background page list sync was calling syncAndDeliver over the remote adapter, which could exceed the 60s timeout for heavy users and block Portal. Route list sync through pageSyncService only via listSync while keeping full delivery on Finish and agent-run paths. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -46,7 +46,7 @@ export function createMindSpacePageListSyncScheduler({
|
||||
|
||||
lastStartedAtByUser.set(userId, currentTime);
|
||||
const task = Promise.resolve()
|
||||
.then(() => syncUserGeneratedPages(userId))
|
||||
.then(() => syncUserGeneratedPages(userId, { listSync: true }))
|
||||
.catch((error) => {
|
||||
logger?.warn?.(
|
||||
`[MindSpace] background page list sync failed for user ${userId}:`,
|
||||
|
||||
@@ -230,8 +230,8 @@ test('page list background sync coalesces in-flight and throttled requests', asy
|
||||
const scheduler = createMindSpacePageListSyncScheduler({
|
||||
now: () => currentTime,
|
||||
minIntervalMs: 30_000,
|
||||
syncUserGeneratedPages(userId) {
|
||||
calls.push(userId);
|
||||
syncUserGeneratedPages(userId, options) {
|
||||
calls.push({ userId, options });
|
||||
return new Promise((resolve) => {
|
||||
resolvers.push(resolve);
|
||||
});
|
||||
@@ -242,19 +242,22 @@ test('page list background sync coalesces in-flight and throttled requests', asy
|
||||
const second = scheduler('user-1');
|
||||
assert.equal(first, second);
|
||||
await Promise.resolve();
|
||||
assert.deepEqual(calls, ['user-1']);
|
||||
assert.deepEqual(calls, [{ userId: 'user-1', options: { listSync: true } }]);
|
||||
|
||||
resolvers.shift()?.({ created: 0, updated: 0, skipped: 0 });
|
||||
await first;
|
||||
|
||||
currentTime += 1_000;
|
||||
assert.equal(scheduler('user-1'), null);
|
||||
assert.deepEqual(calls, ['user-1']);
|
||||
assert.deepEqual(calls, [{ userId: 'user-1', options: { listSync: true } }]);
|
||||
|
||||
currentTime += 30_000;
|
||||
const third = scheduler('user-1');
|
||||
await Promise.resolve();
|
||||
assert.deepEqual(calls, ['user-1', 'user-1']);
|
||||
assert.deepEqual(calls, [
|
||||
{ userId: 'user-1', options: { listSync: true } },
|
||||
{ userId: 'user-1', options: { listSync: true } },
|
||||
]);
|
||||
resolvers.shift()?.({ created: 0, updated: 0, skipped: 0 });
|
||||
await third;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user