Seeds: guardSeedExit() — a run that ends early exits 1 with the reason, never a silent 0

payload run starts the CLI with `void start()` and imports the script; when the script's top-level await
is left without live handles, Node exits with code 0 and no output — a success in Coolify's Terminal.
guardSeedExit() (@intecion/ipal-kit/seed, dependency-free) listens for beforeExit: until summary() runs it
prints "[seed] ended before Payload initialized" / "… before the seed finished" and exits 1. createSeeder
marks the run initialized, summary() finished; process.exit paths (normal, errors, the production
refusals) are untouched. Wired into the ipal-site and ipal-form seed templates and the reference seed, so
ipal-kit create sites get it. Tests include a real child process started like payload run.
Docs: seeding.md, deployment.md §4.7, AGENT.md, ipal-reference (+ api.md), CHANGELOG Unreleased.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-10-29 19:19:14 +01:00
co-authored by Claude Opus 5.5
parent 55dc69b69f
commit f789e36636
14 changed files with 277 additions and 9 deletions
+4 -1
View File
@@ -387,7 +387,10 @@ For a seed (script, flags and data format: [seeding.md](./seeding.md)):
1. **dry run** — `SEED_DRY_RUN=1 pnpm payload run scripts/seed-content.ts`, read the planned changes;
2. **Backup now** on the database (§4.6);
3. the real run; check the panel and the site.
3. the real run; check the panel and the site;
4. `echo $?` — `0` after the summary means done. `1` with `[seed] ended before Payload initialized` (or `… before the
seed finished`) means the run stopped early and silently would have looked like a success — the seed's
`guardSeedExit()` caught it (seeding.md); run it again.
The seed script and its dependencies must be in the image (they are when Coolify builds from the whole repo).