Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion apps/webapp/app/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,17 @@ import {
// on webapp startup. The singleton's initializer wires start (gated on
// `clickhouseFactory.isReady()`) and SIGTERM/SIGINT shutdown — mirrors
// runsReplicationInstance.
//
// IMPORTANT: do NOT replace this with `void sessionsReplicationInstance;`.
// `apps/webapp/package.json` declares `"sideEffects": false`, so esbuild
// treats `void <identifier>;` as a pure expression statement and tree-shakes
// the entire import — the singleton's initializer never fires and the
// sessions→ClickHouse logical replication slot stops being consumed. Assigning
// to globalThis is an unambiguous side effect the bundler must preserve. See
// TRI-9864 for the incident write-up.
import { sessionsReplicationInstance } from "./services/sessionsReplicationInstance.server";
void sessionsReplicationInstance;
(globalThis as Record<string, unknown>).__sessionsReplicationInstance =
sessionsReplicationInstance;

const ABORT_DELAY = 30000;

Expand Down
12 changes: 9 additions & 3 deletions apps/webapp/app/v3/services/adminWorker.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@ import { logger } from "~/services/logger.server";
import { runsReplicationInstance } from "~/services/runsReplicationInstance.server";
// Reference-hold the sessions-replication singleton so module evaluation runs
// its initializer (creates the ClickHouse client, subscribes to the logical
// replication slot, wires signal handlers) when the webapp boots. A bare
// side-effect import gets tree-shaken by the bundler.
// replication slot, wires signal handlers) when the webapp boots.
//
// IMPORTANT: do NOT replace with `void sessionsReplicationInstance;`. With
// `"sideEffects": false` in apps/webapp/package.json, esbuild treats `void X;`
// as a pure expression statement and eliminates the import — the singleton
// initializer never fires. Assignment to globalThis is an observable side
// effect the bundler must preserve. See TRI-9864.
import { sessionsReplicationInstance } from "~/services/sessionsReplicationInstance.server";
void sessionsReplicationInstance;
(globalThis as Record<string, unknown>).__sessionsReplicationInstance =
sessionsReplicationInstance;
import { singleton } from "~/utils/singleton";
import { tracer } from "../tracer.server";
import { $replica } from "~/db.server";
Expand Down