Skip to content

Commit 6e58291

Browse files
committed
fix(webapp): adapt the realtime run-id resolver to paginated listRunIds
listRunIds now returns a keyset page ({ runIds, pagination }); read runIds from it. The page is already capped to the requested size, so the manual trim is gone. Also make the run-change event-bus handler registration return a truthy value so the singleton() wrapper doesn't re-attach listeners on dev reloads.
1 parent bcd0de1 commit 6e58291

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

apps/webapp/app/services/realtime/clickHouseRunListResolver.server.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class ClickHouseRunListResolver implements RunListResolver {
2727
const clickhouse = await this.options.getClickhouse(filter.organizationId);
2828
const repository = new RunsRepository({ clickhouse, prisma: this.options.prisma });
2929

30-
const ids = await repository.listRunIds({
30+
const { runIds } = await repository.listRunIds({
3131
organizationId: filter.organizationId,
3232
projectId: filter.projectId,
3333
environmentId: filter.environmentId,
@@ -37,8 +37,7 @@ export class ClickHouseRunListResolver implements RunListResolver {
3737
page: { size: filter.limit },
3838
});
3939

40-
// listRunIds overfetches by one (size + 1) for has-more detection and doesn't
41-
// trim, so enforce the caller's cap here.
42-
return ids.slice(0, filter.limit);
40+
// listRunIds is keyset-paginated; runIds is already capped to page.size (= limit).
41+
return runIds;
4342
}
4443
}

apps/webapp/app/services/realtime/runChangeNotifierHandlers.server.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ import { publishRunChanged } from "./runChangeNotifierInstance.server";
1616
* high-value, env-cheap transitions here.
1717
*/
1818
export function registerRunChangeNotifierHandlers() {
19+
// Return a truthy value in every path so the singleton() wrapper (which uses
20+
// ??=) caches the result and never re-runs this factory — re-running would
21+
// attach duplicate engine-bus listeners on each Remix dev-mode reload.
1922
if (env.REALTIME_NOTIFIER_ENABLED !== "1") {
20-
return;
23+
return true;
2124
}
2225

2326
// Status transitions (checkpoint suspend/resume, pending version, dequeue) —
@@ -70,4 +73,6 @@ export function registerRunChangeNotifierHandlers() {
7073
});
7174

7275
logger.info("[runChangeNotifier] realtime run-change notifier handlers registered");
76+
77+
return true;
7378
}

0 commit comments

Comments
 (0)