Open MercatoDocsSearch docsAPI reference

Framework

Dev Runtime Diagnostics

If the back office stops loading during development, look for the earliest failing process or health check before restarting everything. The development runtime groups process exits, startup activity, browser errors and probe results so you can follow the sequence.

yarn dev collects everything it can observe about the development runtime – process exits, classified logs, startup warmup, browser errors, and a continuous health probe – into one structured runtime state. That state drives three surfaces: the standalone startup splash, an in-app banner on an already-open page, and (opt-in) a local gateway that owns the public application port.

Everything here is development-only. A production build cannot enable it.

What you get by default

Nothing about the default topology changes:

PORT=3000                -> Next.js / Open Mercato runtime
OM_DEV_SPLASH_PORT=4000  -> standalone splash and supervisor API

What is new in this topology:

Runtime health

HealthMeaningPublic URL
startingBeing built, launched, or warmed up.Splash (gateway mode)
readyWarmup passed and the probe is healthy.Application
degradedServing, but a bounded signal is unhealthy.Application
recoveringA recovery action is running.Splash (gateway mode)
unavailableA hard failure prevents serving.Splash (gateway mode)

The legacy ready / failed fields on GET /status are a projection of this state and keep their existing meaning for current consumers.

The continuous probe

Once the full startup warmup opens the READY gate, the supervisor polls GET /api/healthz on the managed runtime. It never re-runs the login warmup and never logs a success.

OM_DEV_RUNTIME_PROBE_INTERVAL_MS=5000          # how often to probe
OM_DEV_RUNTIME_PROBE_TIMEOUT_MS=1500           # must stay below the interval
OM_DEV_RUNTIME_PROBE_FAILURE_THRESHOLD=3       # consecutive failures -> degraded
OM_DEV_RUNTIME_PROBE_RECOVERY_THRESHOLD=2      # consecutive successes -> ready

GET /api/healthz stays the minimal infrastructure contract – 200 {status:"ok"} or 503 {status:"degraded"}, with no secrets, dependency details, tenant data, or stack traces. It is not a diagnostics endpoint.

The in-app banner

The banner renders only for starting, degraded, recovering, and unavailable. It polls the dev-only status bridge every two seconds.

Runtime degraded · Database schema mismatch
Relation `sandboxs` is missing                         [Show details] [×]

Turn the banner off without losing collection:

OM_DEV_RUNTIME_BANNER=off

Turn everything off:

OM_DEV_RUNTIME_DIAGNOSTICS=off

Both default to following the dev splash, and both stay off in CI.

Opt-in gateway mode

Gateway mode puts a small local server on the public port and moves the managed Next.js runtime to an internal loopback port:

OM_DEV_RUNTIME_MODE=proxy yarn dev
PORT=3000                 -> Open Mercato dev runtime gateway
auto (or OM_DEV_UPSTREAM_PORT) -> managed Next.js runtime, loopback only
OM_DEV_SPLASH_PORT=4000   -> supervisor diagnostics API

Why you might want it: opening the application URL during a failed startup shows readable diagnostics instead of a connection error or a generic framework page. The supervisor also stays alive after a startup-stage failure, so you can run a recovery action without restarting the terminal process.

RequestGateway behavior
/__open-mercato/*Handled by the gateway; never proxied to the app.
HTML navigation while starting / recovering / unavailableSplash fallback.
HTML navigation while ready / degradedProxied to the upstream.
/api/*, /_next/*, static assetsAlways proxied, status and body preserved.
HMR WebSocket upgradeForwarded raw; closed cleanly when the upstream is gone.

A business API error is never replaced by splash HTML: only a real browser navigation (GET/HEAD, Accept: text/html, Sec-Fetch-Mode absent or navigate) can receive the fallback.

The gateway is a development aid, not a production reverse proxy. It binds to loopback by default and fails with a readable error on a port collision rather than silently moving.

Recovery actions

The splash exposes a fixed allowlist. Request input selects an enum member and nothing else – it can never name a binary, append a flag, or change a working directory.

ActionEffect
generateReruns the generator stage, then restarts the runtime.
migrateApplies database migrations after explicit confirmation, then restarts.
restartRestarts the managed runtime through the existing supervisor.
logsRead-only bounded snapshot; not a mutating action.

Only one mutating action runs per runtime generation, and a completion from an older generation can never overwrite newer state.

Warning

migrate applies database changes and is not automatically reversible. Rollback is a separate operator task. generate, restart, and log inspection are recoverable by rerunning the supervisor.

Privacy

Diagnostics stay local and bounded:

Reference

Previous: Data Engine (write layer) · Next: Error Reporting