Skip to content

fix(scheduler.registry): ensure started_at always populated on cron fires#60

Merged
finedesignz merged 1 commit into
mainfrom
fix/registry-started-at
May 26, 2026
Merged

fix(scheduler.registry): ensure started_at always populated on cron fires#60
finedesignz merged 1 commit into
mainfrom
fix/registry-started-at

Conversation

@finedesignz
Copy link
Copy Markdown
Owner

Summary

PR #55 fixed insertRunV2's JS default, but [scheduler.registry] fire failed: null value in column started_at was STILL appearing in prod logs.

Two remaining gaps closed:

  1. hub/src/db/dal.ts insertDeploymentRun — was passing literal JS null for started_at when status === 'pending'. Coolify webhooks hitting this path produced NOT NULL violations. Now always now().

  2. hub/src/db/scheduled-tasks-dal.ts insertRunV2 — SQL now wraps the bound started_at in COALESCE(_, now()). Belt-and-suspenders: even if a future caller passes null explicitly, the server resolves it.

Schema migration ALTER COLUMN started_at SET DEFAULT now() from PR #55 is already in schema.sql and runs on boot via migrate.ts.

Test plan

  • bun test hub/test/insert-run-started-at.test.ts — 5 pass / 0 fail
  • New regression case: explicit started_at: null still produces a Date + SQL contains COALESCE
  • New insertDeploymentRun test verifies no NULL slot

PR #55 fixed insertRunV2's JS-side default, but the registry→dispatcher
cron-fire path was STILL surfacing "null value in column started_at"
in prod logs. Hardens two remaining gaps:

1. hub/src/db/dal.ts insertDeploymentRun — was inserting NULL into
   started_at when status='pending' (coolify-webhook deployment-marker
   rows). Now always now(). started_at is "row created"; that's
   correct for pending too.

2. hub/src/db/scheduled-tasks-dal.ts insertRunV2 — SQL now wraps the
   bound started_at in COALESCE(_, now()), so even an accidentally-null
   bind from a future caller resolves server-side. JS-side default
   (input.started_at ?? new Date()) stays as the primary guard.

Schema.sql already has ALTER COLUMN started_at SET DEFAULT now() from
PR #55 — that runs on every boot via migrate.ts (verified).

Regression tests cover explicit null + the deployment-run path.
@finedesignz finedesignz merged commit 19900c9 into main May 26, 2026
1 check passed
@finedesignz finedesignz deleted the fix/registry-started-at branch May 26, 2026 16:01
finedesignz added a commit that referenced this pull request May 26, 2026
The Titanium JWKS warm at boot called process.exit(1) on any failure,
which has been taking down every Coolify deploy of remo-code-hub since
the upstream Keygen JWKS endpoint at
`/v1/accounts/{ACCOUNT_ID}/.well-known/jwks.json` returns 404.

Architecturally, a stalled Titanium JWKS endpoint should never block the
hub from binding its port — the hub serves health checks, public
webhooks (Coolify, Sentry intake), the web SPA, the scheduler, and the
agent WebSocket, none of which require Titanium JWT verification. Only
license-gated routes do, and those fail closed at request time via
`verifyLicenseJwt` which already lazy-warms on first use through
jose's `createRemoteJWKSet` resolver.

Change: log the warm failure loudly and continue binding the port.
Misconfiguration remains visible in deploy logs; production stays up.

Unblocks PR #60 (started_at scheduler fix) from going live before the
midnight cron fires.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant