macOS sandbox: Turbopack next build completes work but does not exit, leaving .next/lock open
What version of Codex CLI is running?
codex-cli 0.118.0
What subscription do you have?
ChatGPT Plus
Which model were you using?
gpt-5.4
What platform is your computer?
macOS 26.4.1 (Build 25E253), Darwin 25.4.0, arm64
What terminal emulator and version are you using (if applicable)?
Codex in VS Code / extension-host environment on macOS
What issue are you seeing?
In the Codex macOS sandbox, next build for a Next.js 16.2.0 app using Turbopack appears to complete the build work but the process does not exit cleanly.
Observed behavior inside Codex:
npm run buildreachesCreating an optimized production build ...- the process then remains alive in sleep state with ~0% CPU instead of exiting
- the process keeps
.next/lockopen - a subsequent build reports
Another next build process is already running. - if I kill the stuck build and rerun with webpack instead of Turbopack, the build exits normally
Important detail: Next's own trace output indicates the build work actually finished. In .next/trace-build, next-build completed in about 9 seconds, including static generation and trace collection. The hang appears to be in process teardown / exit, not compilation.
The same project builds successfully outside Codex on the same machine, so this looks environment-specific to the Codex macOS sandbox rather than an application bug.
What steps can reproduce the bug?
- Use Codex on macOS in the default sandboxed environment.
- Open any Next.js 16.2.0 app that uses the default Turbopack production build.
- Run
npm run build. - Wait for the build to reach
Creating an optimized production build .... - Observe that the process remains alive after the build artifacts and
.next/trace-buildindicate completion. - Attempt a second build and observe
Another next build process is already running.
What is the expected behavior?
After the build work completes, next build should exit normally.
Additional information
Relevant environment details observed from inside Codex:
CODEX_SANDBOX=seatbeltCODEX_SANDBOX_NETWORK_DISABLED=1TERM=dumbELECTRON_RUN_AS_NODE=1
What I tested:
- unsetting the
CODEX_*environment variables did not fix the hang in this environment NEXT_TELEMETRY_DISABLED=1 npm run buildstill hungnpm exec next build -- --webpackcompleted successfully and exited normallylsof -p <pid>for the hung process showed.next/lockstill open and no child processes remaining
This makes Turbopack + Codex macOS sandbox teardown the most likely problem area.