Skip to content

fix(store): Issue #670 realpath:false + maintainer suggestions#677

Closed
jlin53882 wants to merge 3 commits intoCortexReach:masterfrom
jlin53882:fix/issue670-v3
Closed

fix(store): Issue #670 realpath:false + maintainer suggestions#677
jlin53882 wants to merge 3 commits intoCortexReach:masterfrom
jlin53882:fix/issue670-v3

Conversation

@jlin53882
Copy link
Copy Markdown
Contributor

Summary

Fix Issue #670: ENOENT from proper-lockfile.realpath() after proactive stale lock cleanup.

Incorporates maintainer feedback from #674 (comment)

Root Cause

The proactive stale lock cleanup (PR #626) deletes a stale .memory-write.lock file. When proper-lockfile subsequently tries to acquire the lock, it calls s.realpath() on the now-deleted file, resulting in ENOENT.

Fix

1. Add

ealpath: false to lockfile.lock()

ypescript const release = await lockfile.lock(this.config.dbPath, { lockfilePath: lockPath, // explicit artifact path realpath: false, // Fix #670: skip realpath() to avoid ENOENT retries: { retries: 10, factor: 2, minTimeout: 1000, // James conservative settings maxTimeout: 30000, }, stale: 10000, onCompromised: (err: unknown) => { isCompromised = true; compromisedErr = err; }, });

Key changes:

  • lockfile.lock(target, { lockfilePath: artifact }) — separates lock TARGET (dbPath) from artifact path

ealpath: false — avoids ENOENT when stale artifact was already deleted

  • lockfilePath explicit option — avoids ambiguity with proper-lockfile v4 mkdir behavior

2. Update stale cleanup for proper-lockfile v4

ypescript if (ageMs > staleThresholdMs && stat.isDirectory()) { rmSync(lockPath, { recursive: true, force: true }); }

  • Only removes DIRECTORY artifacts (proper-lockfile v4 uses mkdir)
  • Uses
    mSync instead of unlinkSync for proper directory removal

Validation


  • pm run test:storage-and-schema

  • pm run test:core-regression
  • ✅ Runtime targeted MemoryStore bulk/lock validation (maintainer confirmed)

Related

…ions

- Add realpath:false to avoid ENOENT after stale lock cleanup
- Use lockfilePath option to separate target from artifact path
- Update stale cleanup to only remove directory artifacts
- Keep James conservative retry settings from Issue CortexReach#415
@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.

rmSync with recursive:true still calls rmdir on FILE paths (ENOTDIR).
Use unlinkSync for files, rmSync for directories.
…4 mkdir

Pre-creation created a FILE at lockPath. proper-lockfile v4 creates a DIRECTORY
at the same path (since lockPath ends with .lock). This causes ENOTDIR when
proper-lockfile tries to rmdir a file path.

With realpath:false, pre-creation is no longer needed.
@jlin53882 jlin53882 closed this Apr 20, 2026
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