Skip to content

Payload scripts can exit before writing to disk #16381

@atimmer

Description

@atimmer

Describe the Bug

We run all sorts of CI scripts related to Payload. We use Turborepo to cache the outputs. This all works fine, but we started to have issues where sometimes dependent scripts would fail.

We debugged it to Payload scripts sometimes not writing the relevant file in time for Turborepo to pick it up. It seems that the Node.js process can exit before the file is written.

Link to the code that reproduces this issue

https://github.com/atimmer/payload-cli-startup-repro/

Reproduction Steps

Run this in the repro repository:

corepack enable
pnpm install
pnpm repro

What the repro script does:

  1. Delete the output file in testing.
  2. Run the payload script to generate a db schema
  3. Verify whether the file is present immediately after

On my machine this reproduces cleanly every time, but as it is a timing issue, it might not reproduce always for other machines.

Which area(s) are affected?

area: core

Environment Info

❯ pnpm --filter=ucms payload info

> ucms@1.0.0 payload /Users/anton/Code/Freave/MonoMisset/apps/ucms
> cross-env NODE_OPTIONS=--no-deprecation payload info

This project is configured to use pnpm because /Users/anton/Code/Freave/MonoMisset/package.json has a "packageManager" field

Binaries:
  Node: 22.17.1
  npm: 10.9.2
  Yarn: N/A
  pnpm: 10.33.0
Relevant Packages:
  payload: 3.82.1
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Wed Nov  5 21:32:38 PST 2025; root:xnu-11417.140.69.705.2~1/RELEASE_ARM64_T6031
  Available memory (MB): 65536
  Available CPU cores: 16

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions