Skip to content

Commit 5f14bf3

Browse files
committed
fix(webapp): gate runTableV2 on native realtime and drop the Electric shape merge
The Electric dual-shape merge was a bridge to let the Electric backend observe v2 runs during the cutover, but Electric is short-lived and the merge taxed every tag/batch realtime feed with a second long-poll the moment it deployed. Gate the v2 run table on the native realtime backend instead (the native client is table-agnostic and observes v2 runs directly), so a run only routes to task_run_v2 once its org is on native. Remove the merge module and restore the single-table Electric proxy. The cross-table correctness work stays: a v2 run can still have a cross-table parent or child once an org flips, so the cancelRun cascade, metadata parent/root routing, the one-time-token claim, and the findRuns guard all still apply regardless of realtime backend.
1 parent 0143ade commit 5f14bf3

9 files changed

Lines changed: 107 additions & 758 deletions

apps/webapp/app/runEngine/concerns/idempotencyKeys.server.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,11 @@ export class IdempotencyKeyConcern {
247247
| Record<string, unknown>
248248
| null
249249
| undefined) ?? null;
250-
if (shouldUseV2RunTable(orgFeatureFlags)) {
250+
if (
251+
shouldUseV2RunTable(orgFeatureFlags, {
252+
nativeRealtimeEnabled: env.REALTIME_BACKEND_NATIVE_ENABLED === "1",
253+
})
254+
) {
251255
// Key the claim on (envId, token), task-independent, to match the DB's
252256
// task-independent oneTimeUseToken constraint (see the constant's
253257
// comment). The TTL is a fixed pipeline-dwell bound, NOT the customer
@@ -426,7 +430,9 @@ export class IdempotencyKeyConcern {
426430
// a pathological client. shouldUseV2RunTable is checked first so a v2 org
427431
// skips the mollifier-flag resolve entirely.
428432
const claimEligible =
429-
shouldUseV2RunTable(orgFeatureFlags) ||
433+
shouldUseV2RunTable(orgFeatureFlags, {
434+
nativeRealtimeEnabled: env.REALTIME_BACKEND_NATIVE_ENABLED === "1",
435+
}) ||
430436
(!request.body.options?.resumeParentOnCompletion &&
431437
!request.body.options?.debounce &&
432438
!request.options?.oneTimeUseToken &&

apps/webapp/app/runEngine/services/triggerTask.server.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,9 @@ export class RunEngineTriggerTaskService {
159159
// trigger hot path. Downstream routing is by id format only.
160160
const runFriendlyId =
161161
options?.runFriendlyId ??
162-
(shouldUseV2RunTable(environment.organization.featureFlags)
162+
(shouldUseV2RunTable(environment.organization.featureFlags, {
163+
nativeRealtimeEnabled: env.REALTIME_BACKEND_NATIVE_ENABLED === "1",
164+
})
163165
? RunId.generateKsuid()
164166
: RunId.generate()
165167
).friendlyId;

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

Lines changed: 0 additions & 183 deletions
This file was deleted.

0 commit comments

Comments
 (0)