Skip to content

Commit 9eb95dc

Browse files
committed
fix(webapp): wake live feeds for mid-run metadata updates by their internal run id
The metadata route published the friendly run id, but the realtime router keys single-run feeds by the internal id, so a mid-run metadata.set() never reached a live feed through the fast path (only the backstop caught it). Surface the internal id from the metadata service, which already reads it, and publish that. Also widen a realtime hold-on-empty test backstop so it stops racing the timeout under slow CI.
1 parent 94d9554 commit 9eb95dc

3 files changed

Lines changed: 8 additions & 7 deletions

File tree

apps/webapp/app/routes/api.v1.runs.$runId.metadata.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,10 @@ const { action } = createActionApiRoute(
185185
return json({ error: "Internal Server Error" }, { status: 500 });
186186
}
187187
if (pgResult) {
188-
// Mid-run metadata flush succeeded: publish a run-changed record so a live single-run
189-
// feed reflects metadata.set() without waiting for the next lifecycle event (this
190-
// path doesn't otherwise touch the engine event bus). envId is free; partial record,
191-
// matched by runId. No-op when disabled.
192-
publishChangeRecord({ runId, envId: env.id });
193-
return json(pgResult, { status: 200 });
188+
// Reflect metadata.set() on a live feed before the next lifecycle event. Publish the
189+
// internal id (the router keys single-run feeds by it, not the friendly id from the URL).
190+
publishChangeRecord({ runId: pgResult.runId, envId: env.id });
191+
return json({ metadata: pgResult.metadata }, { status: 200 });
194192
}
195193

196194
// PG miss. Target run is either buffered or genuinely absent.

apps/webapp/app/services/metadata/updateMetadata.server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,8 @@ export class UpdateMetadataService {
355355

356356
return {
357357
metadata: newMetadata,
358+
// Internal id, so callers can publish realtime records keyed how the router indexes feeds.
359+
runId: taskRun.id,
358360
};
359361
}
360362

apps/webapp/test/realtime/notifierHoldOnEmpty.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ describe("NotifierRealtimeClient multi-run live path over the router", () => {
149149
});
150150

151151
it("a matching run created before the window floor is hydrated but dropped (keeps holding)", async () => {
152-
const { client, src, hydrateSpy, resolveSpy, setRows } = makeClient({ livePollTimeoutMs: 120 });
152+
// Generous backstop so the "still holding" assertion can't race a timeout in slow CI.
153+
const { client, src, hydrateSpy, resolveSpy, setRows } = makeClient({ livePollTimeoutMs: 1500 });
153154
setRows([row("run_1", FLOOR_MS + 5_000, { createdAtMs: FLOOR_MS - 10_000, tags: ["t"] })]);
154155

155156
const responsePromise = liveRuns(client);

0 commit comments

Comments
 (0)