fix: report non-zero exit when payload CLI config never settles - #17853
Open
denolfe wants to merge 1 commit into
Open
fix: report non-zero exit when payload CLI config never settles#17853denolfe wants to merge 1 commit into
denolfe wants to merge 1 commit into
Conversation
Default process.exitCode to 1 in bin() so a dropped or never-settling config import exits non-zero instead of silently succeeding. Add try/catch around config load and .catch() on bin.js start() as hardening for configs that throw. Resolves PYLD-3524
Contributor
📦 esbuild Bundle Analysis for payloadThis analysis was generated by esbuild-bundle-analyzer. 🤖
Largest pathsThese visualization shows top 20 largest paths in the bundle.Meta file: packages/next/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_shared.json, Out file: esbuild/exports/shared.js
Meta file: packages/richtext-lexical/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_shared.json, Out file: esbuild/exports/shared_optimized/index.js
DetailsNext to the size is how much the size has increased or decreased compared with the base branch of this PR.
|
denolfe
marked this pull request as ready for review
August 19, 2026 15:30
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Payload CLI could exit 0 after silently failing to load the config.
payload buildand the deploy steps after it then treated a non-build as success. This change makes the CLI report a non-zero exit whenever the config never loads.Resolves PYLD-3524
Root Cause
On an unsupported Node version, the ESM loader can drop the pending config import. The returned promise never settles: it neither resolves nor rejects.
bin.jsruns the CLI as a floatingvoid start()with no rejection handler.runBinScriptimported the config with no guard. A never-settling promise does not keep the event loop alive, so the loop drains and Node exits 0 with no output. Atry/catchor.catch()cannot trap a promise that never rejects, so the exit code itself had to fail closed.Key Changes
bin()setsprocess.exitCode = 1at entry. The success paths still callprocess.exit(0)explicitly. A drained event loop now carries 1 instead of 0.runBinScriptis wrapped in try/catch. A config that throws logs a clear message and exits 1.void start()paths inbin.jsgain.catch(). A rejected startup logs the error and exits 1.Design Decisions
exitCodeguard is the only change that covers a never-settling promise. The try/catch and.catch()cover a config that throws, not one that hangs. Both ship as defense in depth, not as the fix.Overall Flow
flowchart TD A[Config import dropped on unsupported Node] --> B[start promise never settles] B --> C[Event loop drains] C --> D{exitCode guard} D -->|before| E[exit 0, silent success] D -->|after| F[exit 1, failure surfaced]References / Links
payload buildchild-process signal failures.