codex - 💡(How to fix) Fix macOS sandbox: Turbopack next build completes work but does not exit, leaving .next/lock open [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#18895Fetched 2026-04-22 07:50:59
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
labeled ×3unlabeled ×1
RAW_BUFFERClick to expand / collapse

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 build reaches Creating an optimized production build ...
  • the process then remains alive in sleep state with ~0% CPU instead of exiting
  • the process keeps .next/lock open
  • 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?

  1. Use Codex on macOS in the default sandboxed environment.
  2. Open any Next.js 16.2.0 app that uses the default Turbopack production build.
  3. Run npm run build.
  4. Wait for the build to reach Creating an optimized production build ....
  5. Observe that the process remains alive after the build artifacts and .next/trace-build indicate completion.
  6. 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=seatbelt
  • CODEX_SANDBOX_NETWORK_DISABLED=1
  • TERM=dumb
  • ELECTRON_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 build still hung
  • npm exec next build -- --webpack completed successfully and exited normally
  • lsof -p <pid> for the hung process showed .next/lock still open and no child processes remaining

This makes Turbopack + Codex macOS sandbox teardown the most likely problem area.

extent analysis

TL;DR

The issue can likely be worked around by using Webpack instead of Turbopack for production builds in the Codex macOS sandbox environment.

Guidance

  • The problem appears to be specific to the combination of Turbopack and the Codex macOS sandbox, as indicated by successful builds outside this environment and with Webpack.
  • To verify the issue, follow the provided steps to reproduce the bug and observe the process remaining alive after build completion.
  • As a potential mitigation, consider setting environment variables or flags that might affect process teardown, although unsetting CODEX_* variables did not resolve the issue in this case.
  • Using npm exec next build -- --webpack as a workaround allows the build to complete and exit normally, suggesting a Turbopack-specific issue in the Codex environment.

Example

No specific code snippet is applicable here, as the issue seems related to the environment and build tool interaction rather than code.

Notes

The exact cause of the hang during process teardown with Turbopack in the Codex macOS sandbox is not specified, and further investigation into environment variables, sandbox restrictions, or Turbopack's handling of process exit might be necessary for a full resolution.

Recommendation

Apply the workaround by using Webpack for production builds in the Codex macOS sandbox environment, as it allows the build process to exit cleanly, until a more specific fix for Turbopack in this environment is found.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

codex - 💡(How to fix) Fix macOS sandbox: Turbopack next build completes work but does not exit, leaving .next/lock open [1 participants]