Skip to content

generate:types (and other bin commands) hang forever with 100% CPU when tsconfig has a relative rootDir like "./" #18324

Open

Description

@bbkysf

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 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.

Link to the code that reproduces this issue

https://github.com/bbkysf/payload-rootdir-hang

Reproduction Steps

  1. pnpx create-payload-app@latest -t blank repro && cd repro
  2. Move src/payload.config.ts to dev/payload.config.ts (fix its relative imports)
  3. In tsconfig.json:
    • remove "@payload-config" from compilerOptions.paths
    • set "rootDir": "./"
  4. 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

Activity

  1. added
    status: needs-triage
    validate-reproduction
    on Sep 25, 2026
  2. added
    area: core
    and removed
    validate-reproduction
    on Sep 25, 2026
  3. added a commit that references this issue on Sep 25, 2026
    278da2b
  4. avinash-git-24 commented on Sep 28, 2026

    @avinash-git-24

    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!

  5. bbkysf commented on Oct 31, 2026

    @bbkysf
    Author

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugarea: corestatus: needs-triagev3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions