payloadcms / payloadcms/payload

Payload scripts can exit before writing to disk

Open
#16,381 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area: core created-by: Contributor status: needs-triage v3
Dominant language
TypeScript
Stars
44.8k
Forks
4.2k
Avg merge
2d 21h
Merged PRs (30d)
53

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the linked reproduction with corepack enable, pnpm install, and pnpm repro, then trace the Payload script that generates the database schema. Done means the output file is present immediately after the script finishes, including in a regression test for the timing issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.