You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Payload scripts can exit before writing to disk #16381
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.
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
> [email protected] 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
Not sure whether this is related, but we are seeing something that sounds very similar with Payload migration commands. In our case, commands like payload migrate:create and payload migrate will sometimes exit with status 0 and no output. The behavior appears to be flaky.
We first started seeing this after upgrading Payload from 3.74.0 to 3.82.1. We have not been able to reproduce the issue on 3.78.0 or earlier, but it reproduces on every version from 3.79.0 onward (all the way up to current latest 3.84.1).
Examples
payload migrate:create
When running pnpm payload migrate:create:
Expected:
> [email protected] payload /home/runner/work/cms/cms/app
> cross-env NODE_OPTIONS=--no-deprecation PAYLOAD_CONFIG_PATH=src/payload.config.ts payload migrate:create --env production
25l? No schema changes detected. Would you like to create a blank migration file? › (y/N)
[13:17:09] INFO: Starting migration: generating UP statements...
[13:17:09] INFO: Migration UP complete. Generating DOWN statements...
[13:17:09] INFO: Migration DOWN statements generation complete.
✔ No schema changes detected. Would you like to create a blank migration file? … no
import{spawnSync}from'node:child_process'construns=Number(process.env.RUNS||200)letreproduced=falsefor(letrun=1;run<=runs;run++){constresult=spawnSync('bash',['-c','printf "n\\n" | pnpm payload migrate:create --env production'],{stdio: 'pipe',encoding: 'utf8',env: {
...process.env,CI: 'true',GITHUB_ACTIONS: 'true',},},)constoutput=`${result.stdout||''}\n${result.stderr||''}`constmissingPayloadOutput=result.status===0&&!output.includes('No schema changes detected')&&!output.includes('Migration created at')&&!output.includes('Starting migration:')if(missingPayloadOutput){reproduced=trueconsole.error(`Reproduced on run ${run}: exited 0 with no Payload migration output.`)console.error(output)process.exit(1)}console.log(`run ${run}: exit=${result.status}`)//console.error(output)}if(!reproduced){console.log(`No silent exit after ${runs} runs.`)}
Result: payload version 3.79.0 and later were reproduced on multiple runs (exited 0 with no Payload migration output). We were not able to reproduce it for payload version 3.78.0 and earlier. Example of a run using 3.82.1:
RUNS=500 node scripts/repro-migrate-create.mjs
run 1: exit=0
run 2: exit=0
run 3: exit=0
run 4: exit=0
run 5: exit=0
run 6: exit=0
run 7: exit=0
run 8: exit=0
run 9: exit=0
run 10: exit=0
run 11: exit=0
run 12: exit=0
run 13: exit=0
run 14: exit=0
run 15: exit=0
run 16: exit=0
run 17: exit=0
run 18: exit=0
run 19: exit=0
run 20: exit=0
run 21: exit=0
run 22: exit=0
run 23: exit=0
run 24: exit=0
run 25: exit=0
run 26: exit=0
run 27: exit=0
Reproduced on run 28: exited 0 with no Payload migration output.
> [email protected] payload /home/albin/Dev/cms/app
> cross-env NODE_OPTIONS=--no-deprecation PAYLOAD_CONFIG_PATH=src/payload.config.ts payload migrate:create --env production
Activity
albinronnkvist commentedon May 19, 2026
Not sure whether this is related, but we are seeing something that sounds very similar with Payload
migrationcommands. In our case, commands likepayload migrate:createandpayload migratewill sometimes exit with status0and no output. The behavior appears to be flaky.We first started seeing this after upgrading Payload from
3.74.0to3.82.1. We have not been able to reproduce the issue on3.78.0or earlier, but it reproduces on every version from3.79.0onward (all the way up to current latest3.84.1).Examples
payload migrate:create
When running
pnpm payload migrate:create:Expected:
Actual:
payload migrate
When running
pnpm run payload migrate:Expected:
Actual:
Environments
We have observed this behavior in:
A local Ubuntu machine
We ran this script in our project (based on the script in payload-cli-startup-repro):
Result: payload version
3.79.0and later were reproduced on multiple runs (exited 0 with no Payload migration output). We were not able to reproduce it for payload version3.78.0and earlier. Example of a run using3.82.1:Payload info:
Hosted GitHub Actions runners using Ubuntu
We first started seeing these issues in the workflows after upgrading Payload from
3.74.0to3.82.1.For example, this step is flaky as described in the examples above:
We use bash:
Runner info: