learn
apps/

Flush worker

BullMQ worker that flushes Redis room state to durable Prisma snapshots.

The worker reads each dirty snapshot, inserts a new scene revision only when the database is behind, and retains the latest revisions. It touches nothing live: presence and previews never pass through here, so a room can be busy without ever being flushed mid-thought — the debounce decides when a snapshot is durable.

What it owns

  • Scheduled flushes of dirty rooms from Redis to Postgres
  • Recovery sweeps that re-schedule anything left dirty
  • Room message and memory metrics logging

Files

File list and purposes from the folder README.

FilePurpose
src/index.tsWorker entry, flush callback, timers, and shutdown.
package.jsonWorkspace scripts and dependencies.
tsconfig.jsonTypeScript config.

Dependencies

No runtime dependencies.

Development and tooling (3)
LibraryVersion rangeWhy it is used here
@types/node26.4.1Type declarations for Node.js built-ins.
tsx^4.23.13Runs and watches TypeScript sources for development and tests.
TypeScript7.0.2Compiles the workspace and type-checks every package.

Dependencies as of commit b0026d9.

Internal packages used

flush-worker folder
BrowserAPIRealtimeCacheDatabaseShareddurableephemeral

Talks to

Sources: apps/flush-worker/README.md, apps/flush-worker/src/README.md, apps/flush-worker/src/index.ts (documented at commit b0026d9)

On this page