Skip to content

Fix EPERM crash on Windows ACL corruption + enable DIRS mutable container for fallback paths#232

Open
NOirBRight wants to merge 1 commit into
nicobailon:mainfrom
NOirBRight:fix/eperm-ensure-accessible-dir
Open

Fix EPERM crash on Windows ACL corruption + enable DIRS mutable container for fallback paths#232
NOirBRight wants to merge 1 commit into
nicobailon:mainfrom
NOirBRight:fix/eperm-ensure-accessible-dir

Conversation

@NOirBRight
Copy link
Copy Markdown

Problem

Pi crashes on startup on Windows Azure AD/Entra ID machines when the NTFS ACL on the global temp directory is corrupted (typically after wake-from-sleep). ensureAccessibleDir in src/extension/index.ts throws an uncaught EPERM on mkdirSync, which propagates up through Pi's extension loader and kills the entire Pi process.

A secondary issue: RESULTS_DIR and ASYNC_DIR are exported as export const (primitive string) bindings, making them read-only in all ES module consumers. A fallback path set by ensureAccessibleDir cannot propagate to these consumer modules.

Changes

  1. EPERM-tolerant ensureAccessibleDir - catches EPERM/EACCES, attempts recovery, falls back to pid-scoped path
  2. DIRS mutable container - export const DIRS = { results, async, chain, artifacts } replaces direct RESULTS_DIR/ASYNC_DIR usage; object properties are mutable while the binding remains const (ES module compatible)
  3. All 11 consumer module sites migrated to DIRS.results/DIRS.async
  4. 9 new unit tests pass

Files changed (11)

  • src/extension/index.ts, src/shared/types.ts, src/extension/doctor.ts
  • src/runs/background/async-execution.ts, async-job-tracker.ts, async-resume.ts, run-id-resolver.ts, run-status.ts, stale-run-reconciler.ts
  • src/runs/shared/nested-events.ts
  • test/unit/ensure-accessible-dir.test.ts (new)

…IRS mutable container

- ensureAccessibleDir now catches EPERM/EACCES from mkdirSync, attempts
  rmSync+retry, and falls back to ${dirPath}-${process.pid} when both fail
- Return type changed from void to string (actual path used)
- DIRS mutable container replaces export const RESULTS_DIR/ASYNC_DIR for
  runtime path override propagation
- All 11 consumer module sites migrated to use DIRS.results/DIRS.async
- Backward-compatible RESULTS_DIR/ASYNC_DIR aliases retained in types.ts
- Unit tests for ensureAccessibleDir + DIRS container (9 pass)

Refs: nicobailon/pi-subagents EPERM crash on Windows ACL corruption
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant