angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Persistent compiler cache (lmdb) crashes with SIGABRT in sandboxed environments — no graceful fallback

Open Prontsevich opened this issue 5 months ago • 3 comments

Description

Command (and args if any)

ng build / @angular/build:application (any Angular 17+ project)

Is this a regression?

No

The exception or error

When running an Angular build inside a sandboxed environment that restricts System V IPC (e.g. OpenAI Codex's macOS seatbelt sandbox), the process crashes with SIGABRT (exit code 134) during persistent compiler cache initialization. No error message is shown — the process simply aborts.

The crash happens in @angular/build/src/tools/esbuild/angular/compiler-plugin.js when creating an LmdbCacheStore:

// compiler-plugin.js:73
const { LmdbCacheStore } = require('../lmdb-cache-store');
cacheStore = new LmdbCacheStore(
  path.join(pluginOptions.sourceFileCache.persistentCachePath, 'angular-compiler.db')
);

The existing try/catch around this code does not help because the crash is a native SIGABRT (exit 134), not a JavaScript exception. The process is killed by the OS before the catch block can execute.

Minimal Reproduction

  1. On macOS, npm install lmdb in any project
  2. Create a sandbox profile that restricts System V IPC:
    (version 1)
    (deny default)
    (allow process-exec process-fork signal)
    (allow file-read* file-write* file-ioctl)
    (allow sysctl-read)
    (allow mach-lookup)
    (allow ipc-posix-sem)
    (allow pseudo-tty)
    (allow network*)
    (allow system-socket)
    
  3. Run: sandbox-exec -f profile.sb node -e "require('lmdb').open({path:'/tmp/test'})" → Abort trap: 6

Root cause: the @lmdb/lmdb-darwin-arm64 prebuilt binary is compiled with MDB_USE_SYSV_SEM (System V semaphores). Filed upstream: kriszyp/lmdb-js#359

Environment

Angular CLI: 21.x @angular/build: 21.2.15 Node.js: 24 OS: macOS Darwin arm64 Package manager: pnpm 11.7.0

Prontsevich avatar Jun 18 '26 14:06 Prontsevich

Workaround

Until the root cause is fixed upstream (kriszyp/lmdb-js#359), you can disable Angular's persistent compiler cache to avoid the crash. Build output is identical; only incremental build speed is affected.

Option 1: Environment variable

Set CI=true before building. Angular's normalize-cache.js checks process.env.CI and skips lmdb entirely.

CI=true ng build

For OpenAI Codex users, set it permanently in .codex/config.toml:

[shell_environment_policy]
set = { CI = "true" }

Option 2: angular.json

Disable the cache in your project config:

{
  "projects": {
    "your-app": {
      "cli": {
        "cache": {
          "enabled": false
        }
      }
    }
  }
}

Background

The crash happens because the @lmdb/lmdb-darwin-arm64 prebuilt binary uses System V semaphores (semget/semop/semctl), which are blocked by macOS sandbox policies (e.g. OpenAI Codex's seatbelt sandbox). The try/catch in compiler-plugin.js:73 around LmdbCacheStore initialization does not catch this because SIGABRT is a native signal that kills the process before JavaScript can handle it.

Upstream fix tracked in kriszyp/lmdb-js#359.

Prontsevich avatar Jun 18 '26 14:06 Prontsevich

Closing this issue as it is not caused by the Angular CLI and is not actionable from our side.

alan-agius4 avatar Jun 18 '26 18:06 alan-agius4

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.