generate:types (and other bin commands) hang forever with 100% CPU when tsconfig has a relative rootDir like "./"
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- node.js, typescript
Research direction
Start with getTSConfigPaths() in packages/payload/src/config/find.ts and the findUpSync implementation in packages/payload/src/utilities/findUp.ts. Reproduce the hang with the linked setup or the listed tsconfig changes, then verify that pnpm payload generate:types no longer loops and either generates types or reports that the config cannot be found.
Written by the indexing model from the issue text.
Description
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 cores
- Dominant language
- TypeScript
- Stars
- 45.5k
- Forks
- 4.3k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 309
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from payloadcms/payload
-
Grid view: show the file placeholder when a thumbnail image fails to loadPossibly taken @lazerg claimed this today. OpenBug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
payloadcms/payload#19181 ·
Maintainers usually reply within 1 day
-
WhereBuilder throws "Cannot read properties of undefined (reading 'value')" when the list URL filters on a field that is not filterablePossibly taken A pull request linked to this issue is open or already merged. OpenBug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
payloadcms/payload#19002 · 1 comment ·
Maintainers usually reply within 1 day
-
Regression: `findByID` with `disableErrors: true` throws `NotFound` for null/empty ids since 3.91.0Possibly taken @Krrishkumar125 claimed this 7 days ago. Openarea: core Bug invalid-reproduction status: needs-triage v3
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
payloadcms/payload#18935 · 2 comments ·
Maintainers usually reply within 1 day
-
bug: Local API call with req resets req.fallbackLocale to defaultLocalePossibly taken A pull request linked to this issue is open or already merged. Openarea: core Bug created-by: Contributor
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
payloadcms/payload#18768 ·
Maintainers usually reply within 1 day
-
[plugin-multi-tenant] Infinite redirect loop with custom tenantFieldName and isGlobal collectionsPossibly taken A pull request linked to this issue is open or already merged. OpenBug plugin: multi-tenant status: needs-triage v3
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
payloadcms/payload#18690 ·
Maintainers usually reply within 1 day
All issues in payloadcms/payload
Similar issues
-
Parallel reticle_verify opens per-flow leases without the source lease's ignoreHTTPSErrorsPossibly taken @as992949791 claimed this today. Opengood first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
reticlehq/reticle#2033 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
area:quality p3-medium ready-for-agent type:docs
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
fderuiter/deruiter.dev#3589 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
manfredsteyer/angular-oauth2-oidc#1514 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
marmelab/react-admin#11431 ·
Maintainers usually reply within 1 day