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
generate:types (and other bin commands) hang forever with 100% CPU when tsconfig has a relative rootDir like "./" #18324
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:
With "rootDir": "./", findUpSync({ dir: './' }) loops forever:
path.parse('./').root === ''
path.dirname('./') === '.', and path.dirname('.') === '.'
so dir never equals root and 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.
pnpx create-payload-app@latest -t blank repro && cd repro
Move src/payload.config.ts to dev/payload.config.ts (fix its relative imports)
In tsconfig.json:
remove "@payload-config" from compilerOptions.paths
set "rootDir": "./"
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.
Hey team, getTSConfigPaths in packages/payload/src/config/find.ts passes relative rootDir ("./") into findUpSync, causing an infinite loop when path.dirname(".") === ".". Happy to open a PR resolving rootDir/outDir against tsConfigDir!
Also reproduces on [email protected] (main): findConfig() with the linked repro's tsconfig spins at 100% CPU and never returns. Removing rootDir makes it resolve src/payload.config.ts immediately. #18327 fixes it on 3.x; the same patch applies to main.
Activity
fix: infinite loop in findConfig when tsconfig rootDir is relative
avinash-git-24 commentedon Sep 28, 2026
Hey team,
getTSConfigPathsinpackages/payload/src/config/find.tspasses relativerootDir("./") intofindUpSync, causing an infinite loop whenpath.dirname(".") === ".". Happy to open a PR resolvingrootDir/outDiragainsttsConfigDir!bbkysf commentedon Oct 31, 2026
Also reproduces on
[email protected](main):findConfig()with the linked repro's tsconfig spins at 100% CPU and never returns. RemovingrootDirmakes it resolvesrc/payload.config.tsimmediately. #18327 fixes it on 3.x; the same patch applies tomain.fix: address six additional Payload v4 core and plugin issues [skip ci]