generate:types (and other bin commands) hang forever with 100% CPU when tsconfig has a relative rootDir like "./"
Describe the Bug
When PAYLOAD_CONFIG_PATH is not set and tsconfig.json has no "@payload-config" path, payload generate:types hangs indefinitely at 100% CPU with no output.
Cause: in getTSConfigPaths() (packages/payload/src/config/find.ts), srcPath is taken directly from compilerOptions.rootDir without being resolved to an absolute path:
const srcPath = tsConfig.compilerOptions?.rootDir || path.resolve(process.cwd(), 'src')With "rootDir": "./", findUpSync({ dir: './' }) loops forever:
- path.parse('./').root === ''
- path.dirname('./') === '.', and path.dirname('.') === '.'
- so
dirnever equalsrootand the while(true) loop never exits.
Suggested fix: resolve rootDir (and outDir) relative to the tsconfig directory, e.g. path.resolve(tsConfigDir, tsConfig.compilerOptions.rootDir) Optionally, findUpSync/findUp could also guard against dirname(dir) === dir.
Workaround: set PAYLOAD_CONFIG_PATH, or add "paths": { "@payload-config": ["./path/to/payload.config.ts"] } to tsconfig.json.
Link to the code that reproduces this issue
https://github.com/bbkysf/payload-rootdir-hang
Reproduction Steps
pnpx create-payload-app@latest -t blank repro && cd repro- Move
src/payload.config.tstodev/payload.config.ts(fix its relative imports) - In
tsconfig.json:- remove
"@payload-config"fromcompilerOptions.paths - set
"rootDir": "./"
- remove
- Run
pnpm payload generate:types
Expected: types are generated, or an error says the config can't be found. Actual: the process hangs forever with no output at 100% CPU (one core pinned). It never exits.
findUpSync({ dir: './' }) in packages/payload/src/utilities/findUp.ts loops forever because path.dirname('.') === '.' and path.parse('./').root === '', so dir !== root is always true.
Setting PAYLOAD_CONFIG_PATH, or adding the @payload-config path back, avoids the hang.
Which area(s) are affected?
area: core
Environment Info
Binaries:
Node: 24.18.0
pnpm: 11.20.0
Relevant Packages:
payload: 3.90.0
next: 16.3.3
@payloadcms/db-postgres: 3.90.0
@payloadcms/next: 3.90.0
@payloadcms/richtext-lexical: 3.90.0
react: 19.2.6
Operating System:
Debian GNU/Linux 13 (trixie) on WSL2 (kernel 6.18.33.2-microsoft-standard-WSL2), Windows 11
x64, 8 coresSource: payloadcms/payload