Skip to content

[Windows][Desktop] Identical codex-app-tools refresh fails with unlink EBUSY during Local Work startup #55417

Open

Description

@c4jack

Environment

  • Codex Desktop 26.1013.40934, build 20770.
  • OS build: Windows NT 10.0.26300.0 (x64).
  • Windows package: OpenAI.Codex 26.1013.4894.0, x64.
  • Incident observed in the unmodified official application on 2026-10-20, 07:24 UTC+08:00 (2026-10-19, 23:24 UTC).

Observed behavior in the official application

Two bundled-plugin sync completions were followed by Local Work executor planned restarts approximately five seconds apart. Startup attempt 3 failed while replacing executor-plugins/codex-app-tools/server.mjs, with EBUSY from unlink. The executor retried and connected on attempt 4. Plugin-list requests also timed out during this startup episode, making the application appear to be continually loading tools or disconnected.

Selected log fields below retain UTC timestamps; paths and unrelated identifiers are omitted:

2026-10-19T23:24:36.988Z [tpp-local-executor] event=lifecycle_stop reason=planned_restart
2026-10-19T23:24:42.171Z [tpp-local-executor] event=lifecycle_stop reason=planned_restart
2026-10-19T23:24:42.889Z [tpp-local-executor] Local Work executor startup failed attempt=3 errorCode=EBUSY
  EBUSY: resource busy or locked, unlink '<executor-plugin-root>/server.mjs'
2026-10-19T23:24:42.891Z [tpp-local-executor] Scheduling Local Work executor restart attempt=3 delayMs=1000 reason=startup_failure
2026-10-19T23:24:57.440Z [tpp-local-executor] Local Work executor connected to rendezvous attempt=4
2026-10-19T23:25:07.177Z [electron-message-handler] mcp_request_timeout method=plugin/installed

The file-copy stack includes Node's mayCopyFile, copyDir, and the application's executor plugin preparation path (readCapabilityRoots). This concerns the built-in codex-app-tools runtime copy.

Expected: an unchanged bundled plugin should be reused without rewriting files in use or disrupting executor startup.

Deterministic Windows reproduction

We reproduced the file-operation failure in an isolated local harness using the original plugin synchronization function and the installed bundled plugin files:

  1. Perform the initial synchronization into an empty temporary destination.
  2. Open the destination server.mjs with a real Windows file handle: FileMode.Open, FileAccess.Read, FileShare.Read. Keep the handle open. This permits reading but denies replacement/deletion.
  3. Invoke synchronization again without changing the source. The original recursive copy fails with EBUSY, syscall unlink.
  4. Under the same held lock, invoke a candidate synchronization implementation that skips byte-identical files. It succeeds without copying files or writing configuration; server.mjs modification time remains unchanged.

This reproduces the Windows lock condition, not the identity of the process holding the file in the original incident. The actual incident's lock owner remains unknown.

Local candidate and verification

The candidate serializes synchronization per destination directory, compares file contents before copying, and writes the generated .mcp.json only when the effective configuration changes. The bundled source .mcp.json is excluded from copying because the destination configuration is generated afterward.

All eight isolated regression checks passed:

Check Result
Fresh destination Same file contents and effective configuration as the original function
Real Windows read-sharing lock Original: EBUSY; candidate: success, zero copies/writes
Changed source bytes Changed server.mjs copied; identical files untouched
Changed effective configuration Configuration updated without recopying the server
12 concurrent refresh calls Maximum concurrent copies: 1; server copied once; configuration written once
Failure followed by queued/later calls Later calls recover; queue is not poisoned
Unavailable bundled plugin Preserves null result without writes
Unexpected destination access error Error remains visible rather than silently ignored

These are local candidate results, not a claim that OpenAI has confirmed or shipped a fix. The candidate does not remove every planned restart, and genuinely changed files can still fail to update while locked.

Suggested upstream fix

Skip identical runtime files and unchanged generated configuration, and serialize updates targeting the same executor plugin directory. Also review overlapping refresh/startup scheduling and the shutdown/update ordering when file content really changes.

Earlier retained logs already contain planned restarts, so this is not established as a regression introduced by this particular version. The timing suggests overlapping refreshes contribute to the failure, but that causal link needs upstream verification. This report is limited to the local executor startup/file-lock failure; it does not attribute separate model-stream network errors to this issue.

No account data, conversation content, user-specific filesystem paths, binaries, or full extracted application source are included.

Activity

  1. added
    bug
    app
    windows-os
    skills
    on Oct 20, 2026
  2. github-actions commented on Oct 20, 2026

    @github-actions
    Contributor

    Potential duplicates detected. Please review them and close your issue if it is a duplicate.

    Powered by Codex Action

  3. fbernklau commented on Oct 20, 2026

    @fbernklau

    Additional Windows Desktop + WSL reproduction on 2026-10-20, with a cancellation/serialization mechanism relevant to this issue.

    Same Windows package 26.1013.4894.0, build 20770. The live error here is ENOENT unlink on the staged .codex-plugin/plugin.json; earlier retained logs also show EBUSY on server.mjs. There is only one main Desktop process, and the plugin source/target are ordinary Windows directories.

    The important new finding is that cancelling a queued registration can release the queue while its underlying readCapabilityRoots() operation continues. A subsequent registration can therefore overlap writes to the same plugin destination. The isolated test below reproduces the queue overlap in 10/10 runs and eliminates it in 10/10 runs when the queue drains the underlying operation. This is a demonstrated mechanism, not proof that concurrent copies have been traced inside the live app.

    Related WSL discovery/performance issue: #26149. This is an existing profile after earlier troubleshooting, not a clean-install reproduction. No packaged app code was modified.

    Sanitized diagnostic report, timings and suggested product corrections
    Windows Desktop + WSL: slow skill discovery and executor plugin copy failure
    Investigation: 2026-10-20. Status: unresolved in the installed Desktop app.
    
    Environment
    - Windows packaged Desktop app 26.1013.4894.0 (build 20770).
    - WSL Ubuntu-24.04. Bundled Linux agent 0.163.0-alpha.10.2.
    - Normal Windows Codex home, accessed by the WSL backend through /mnt/c.
    - 22 installed plugins / 91 discovered skills; 15 saved project roots.
    - One main Desktop process. Source and target plugin directories are normal
      Windows directories, not directory links. Source and destination plugin.json
      exist and are normal files at inspection time.
    - No plugins disabled, no production configuration changed in this investigation.
    
    A. Skill discovery
    Using the same bundled Linux backend with a temporary SQLite snapshot and the
    existing Codex home, sequential requests for one cwd returned:
      initialize                         232 ms
      plugin/installed (without cwds)     403 ms
      skills/list forceReload=false     7948 ms, 91 skills
      skills/list forceReload=false       93 ms, 91 skills (cached)
      skills/list forceReload=true      8381 ms, 91 skills
    These are measurements without strace. They do not represent an end-to-end
    Desktop startup test or a completed fix.
    
    A separate strace run returned 11813 / 241 / 12605 ms for the same skill sequence;
    tracing adds overhead. Across initialization, plugin inventory and all three skill
    queries, there were 28,840 trace lines, including 17,195 readlink calls, 3,253 lstat
    calls, and 1,836 getdents64 calls. These counts are for the entire probe, not one
    skill scan. The traversal includes assets/reference subdirectories of skills.
    Many individually small Windows filesystem operations accumulate; no one long
    filesystem call was identified in this trace.
    
    Installed Desktop code contains forced skills reloads after bundled-plugin
    reconciliation and primary-runtime setup. Main renderer and avatar overlay also
    issue skill queries. This can repeatedly incur cold discovery costs. Exact
    invalidation timing in the live backend has not been instrumented.
    
    Live normal-start log (times UTC, 2026-10-20):
      16:49:24     Desktop main process launched
      16:49:54.185 executor first connected
      16:50:09.235 model/list duration 6 ms, queue wait 13195 ms
      16:50:09.995 skills/list duration 24517 ms, queue wait 367 ms
      16:50:12.573 bundled-plugin reconciliation completed
      16:50:12.577 planned executor restart
      16:50:15.172 executor attempt 2 failed copying plugin.json
      16:50:25.284 executor attempt 3 connected
      16:50:34.913 overlay skills/list duration 20865 ms
      16:50:47.926 thread/resume duration 37916 ms
    The model list itself is fast; local startup/queueing explains a substantial part
    of the misleading 'Loading model' wait. This is not proof of a model service outage.
    
    B. Executor plugin copy failure: concrete cancellation/serialization defect
    Live error:
      ENOENT: no such file or directory, unlink
      <AppData>\Roaming\Codex\web\Codex\executor-plugins\codex-app-tools\
      .codex-plugin\plugin.json
    Stack: fs/promises.unlink -> fs/cp.mayCopyFile -> copyDir -> xc ->
    Fle.readCapabilityRoots -> registerExecutor.
    Earlier logs also contained EBUSY for server.mjs in this directory.
    
    Relevant installed-code behavior (read only, app.asar not modified):
    1. xc unconditionally calls fs.cp(source, sameExecutorPluginRoot,{recursive:true}).
    2. registerExecutor serializes registrations with this.pendingRegistration.
    3. Inside that queue, it awaits abortable(this.readCapabilityRoots(), signal).
    4. The exported abort helper (Ci / de) rejects on abort but does not cancel or
       await completion of the supplied promise.
    5. stop() aborts the signal and startPromise is reset for the next start.
    6. Thus the queue can be released after abort while the old capability-root
       operation (including fs.cp) is still running. A new queued registration can
       start a second operation against the same destination.
    
    Minimal reproduction of this promise/queue behavior:
      10/10 trials with current queue: max 2 simultaneous capability operations.
      10/10 trials with queue waiting for the underlying operation to drain: max 1.
    This is a demonstrated defect in the cancellation/serialization pattern. It is a
    strong explanation for the live copy error, not a direct filesystem trace of two
    simultaneous copies inside the running Desktop process.
    
    Independent Windows filesystem reproduction, bundled node v24.21.0:
      Two inert fixture files; fs.cp(source,target,{recursive:true}).
      Sequential block 1: 25 success, 0 failure.
      Concurrent block 1: 30 success, 13 ENOENT, 7 EPERM (50 total operations).
      Sequential block 2: 25 success, 0 failure.
      Concurrent block 2: 31 success, 13 ENOENT, 6 EPERM (50 total operations).
    The fixture was removed. Installed plugin files were never changed by this test.
    This proves that overlapping copies can produce the observed error class;
    concurrency was deliberately introduced only inside the isolated reproduction.
    
    Recommended product corrections, not yet installed or validated end-to-end
    - Keep registration/copy serialization locked until the underlying operation has
      really completed after cancellation; make stale operations stop before writes.
    - Use a destination-scoped lock for plugin materialization and avoid overwriting
      an unchanged bundled plugin. Preserve the generated MCP definition semantics.
    - Coalesce skill discovery/reload across primary runtime, plugin reconciliation,
      main renderer and overlay; invalidate only when relevant content changes.
    - Avoid blocking model discovery behind expensive local background discovery.
    - Validate cold and warm packaged Desktop starts with WSL, realistic plugin
      inventory and multiple saved project roots, including planned restarts.
    
    Local remediation boundary
    No documented configuration switch was identified that corrects these internal
    queue/copy semantics while preserving the current Desktop/WSL/plugin behavior.
    Deleting the target does not fix concurrent rewrites. Warming an independent CLI
    process does not warm the Desktop backend's in-memory skill cache. Moving the
    whole Codex home, symlinking it, or patching packaged app.asar is not a validated
    repair and was not attempted in this investigation.
    
    Reproduction artifacts in ../work
    - skill-trace-verified-results.json: timings without tracing
    - skill-filesystem-summary.json: aggregate filesystem counts
    - reproduce_executor_abort_overlap.mjs: no-file queue/cancellation reproduction
    - executor-abort-overlap-result.json: its result
    - reproduce_copy_race.mjs: two-file fs.cp reproduction, requires scratch directory
    - copy-race-result.json: Windows bundled-node reproduction result
    Raw traces and inventories contain local paths; they are not needed for an initial
    public issue. This report deliberately omits usernames, project names and tokens.
    Prepared for submission; raw traces and session logs are omitted.
    
    Official reporting instructions
    https://learn.chatgpt.com/docs/reference/troubleshooting#feedback-and-logs
    
    Self-contained queue/abort reproduction (Node; no app files, network or configuration touched)

    Save as reproduce_executor_abort_overlap.mjs and run node reproduce_executor_abort_overlap.mjs.

    // Minimal reproduction of the installed app's promise queue and abort wrapper.
    // No Codex files, settings, network requests or plugin registrations are touched.
    function abortable(p,signal){
     if(signal.aborted){p.catch(()=>{});return Promise.reject(signal.reason);}
     return new Promise((resolve,reject)=>{
      const onAbort=()=>reject(signal.reason);
      signal.addEventListener('abort',onAbort,{once:true});
      p.then(resolve,reject).finally(()=>signal.removeEventListener('abort',onAbort));
     });
    }
    const sleep=ms=>new Promise(resolve=>setTimeout(resolve,ms));
    async function trial(drainBeforeNext){
     let pending=Promise.resolve(),active=0,maxActive=0;
     let started;
     const whenStarted=new Promise(resolve=>started=resolve);
     const task=async()=>{active++;maxActive=Math.max(maxActive,active);started();await sleep(30);active--;};
     function register(signal){
      let operation;
      const result=pending.then(async()=>{signal.throwIfAborted();operation=task();return abortable(operation,signal);});
      pending=drainBeforeNext?result.then(()=>{},()=>{}).then(()=>operation?.catch(()=>{})):result.then(()=>{},()=>{});
      return result;
     }
     const firstAbort=new AbortController();
     const first=register(firstAbort.signal).catch(()=>{});
     await whenStarted;
     firstAbort.abort(new Error('planned restart'));
     const second=register(new AbortController().signal);
     await Promise.all([first,second]);await pending;await sleep(35);
     return maxActive;
    }
    const result={currentQueue:[],queueDrainsUnderlyingOperation:[]};
    for(let i=0;i<10;i++){
     result.currentQueue.push(await trial(false));
     result.queueDrainsUnderlyingOperation.push(await trial(true));
    }
    if(result.currentQueue.some(n=>n!==2)||result.queueDrainsUnderlyingOperation.some(n=>n!==1))throw new Error('Unexpected result');
    console.log(JSON.stringify({meaning:'Maximum concurrent capability operations after abort and re-registration',...result}));

    Observed: currentQueue is ten values of 2; queueDrainsUnderlyingOperation is ten values of 1.

    Could maintainers confirm whether the cancellation/serialization and unchanged-file replacement paths have a fix, and identify the first Windows Desktop build containing it? A durable supported Windows Desktop + WSL solution is needed; moving/copying the whole Codex home, filesystem redirection, or disabling the installed plugin set is not an acceptable long-term remedy for this user.

    Submitted with the user's authorization using Codex assistance. No raw logs, account data, project names or session transcripts are included.

  4. johnmart19 commented on Oct 21, 2026

    @johnmart19

    Additional reproduction on production 26.1016: concurrent copies also produce ENOENT / EPERM

    Independent confirmation of a related executor-plugin copy failure on a newer Windows production build.

    Environment

    • Windows x64.
    • Updater: Codex desktop 26.1016.51333, build 21161, production channel; up_to_date when checked.
    • Windows package version: 26.1016.6573.0.
    • No installed app files, plugin cache, ACLs, account settings or chat databases were modified.

    Application observations (sanitized)

    During one launch, the first Local Work executor attempt connected successfully. A subsequent attempt failed with EPERM while unlinking <userData>/executor-plugins/codex-app-tools/.codex-plugin/plugin.json; the next automatic retry connected. A previous launch also recorded ENOENT while unlinking the same destination.

    Read-only inspection showed unconditional recursive copying to the shared executor-plugin destination during readCapabilityRoots preparation, followed by generated .mcp.json writing. The destination manifest was not ReadOnly and the user had FullControl. This is consistent with an overlapping-copy failure; the precise overlapping application callers have not been instrumented. It is not proof that this explains every unsuccessful UI launch or renderer fault.

    Isolated reproduction

    Run the following as node reproduce-copy-race.mjs in a scratch directory. It uses only synthetic files and leaves its test subtree intact. In a run with the installed bundled Node runtime:

    Case Operations Failures Errors
    Two concurrent copies, ten rounds 20 10 8 ENOENT, 2 EPERM
    Sequential pairs, ten rounds 20 0 None

    This demonstrates the matching filesystem failure mechanism, not the full production scheduling.

    reproduce-copy-race.mjs
    import fs from 'node:fs/promises';
    import path from 'node:path';
    import crypto from 'node:crypto';
    
    async function main() {
      const runId = `${Date.now()}-${crypto.randomUUID().slice(0, 8)}`;
      const rootDir = path.resolve(process.cwd(), `copy-race-temp-${runId}`);
      const sourceDir = path.join(rootDir, 'source');
      const pluginDir = path.join(sourceDir, '.codex-plugin');
    
      await fs.mkdir(pluginDir, { recursive: true });
      await fs.writeFile(
        path.join(pluginDir, 'plugin.json'),
        JSON.stringify({ name: 'test-plugin', version: '1.0.0' }, null, 2),
        'utf8'
      );
    
      for (let i = 1; i <= 20; i++) {
        await fs.writeFile(
          path.join(sourceDir, `file-${String(i).padStart(2, '0')}.txt`),
          `small file content ${i}\n`.repeat(4),
          'utf8'
        );
      }
    
      const recordResult = (stats, settled) => {
        if (settled.status === 'fulfilled') {
          stats.succeededOps += 1;
          return true;
        }
        stats.failedOps += 1;
        const code = settled.reason?.code || settled.reason?.name || 'UNKNOWN';
        stats.errorCodes[code] = (stats.errorCodes[code] || 0) + 1;
        return false;
      };
    
      const concurrent = {
        rounds: 10,
        totalOps: 20,
        succeededOps: 0,
        failedOps: 0,
        roundsSucceeded: 0,
        roundsFailed: 0,
        errorCodes: {},
      };
    
      for (let r = 1; r <= 10; r++) {
        const destDir = path.join(rootDir, `concurrent-round-${String(r).padStart(2, '0')}`);
        await fs.cp(sourceDir, destDir, { recursive: true });
    
        const [res1, res2] = await Promise.allSettled([
          fs.cp(sourceDir, destDir, { recursive: true }),
          fs.cp(sourceDir, destDir, { recursive: true }),
        ]);
    
        const ok1 = recordResult(concurrent, res1);
        const ok2 = recordResult(concurrent, res2);
        if (ok1 && ok2) {
          concurrent.roundsSucceeded += 1;
        } else {
          concurrent.roundsFailed += 1;
        }
      }
    
      const sequential = {
        rounds: 10,
        totalOps: 20,
        succeededOps: 0,
        failedOps: 0,
        roundsSucceeded: 0,
        roundsFailed: 0,
        errorCodes: {},
      };
    
      for (let r = 1; r <= 10; r++) {
        const destDir = path.join(rootDir, `sequential-round-${String(r).padStart(2, '0')}`);
        await fs.cp(sourceDir, destDir, { recursive: true });
    
        const [res1] = await Promise.allSettled([
          fs.cp(sourceDir, destDir, { recursive: true }),
        ]);
        const [res2] = await Promise.allSettled([
          fs.cp(sourceDir, destDir, { recursive: true }),
        ]);
    
        const ok1 = recordResult(sequential, res1);
        const ok2 = recordResult(sequential, res2);
        if (ok1 && ok2) {
          sequential.roundsSucceeded += 1;
        } else {
          sequential.roundsFailed += 1;
        }
      }
    
      console.log(
        JSON.stringify({
          concurrent,
          sequential,
        })
      );
    }
    
    main().catch((err) => {
      console.log(
        JSON.stringify({
          fatalError: true,
          code: err?.code || err?.name || 'UNKNOWN',
          message: err?.message || String(err),
        })
      );
      process.exitCode = 1;
    });

    Candidate fix and regression checks

    Serialize preparation by normalized destination across controller/window lifetimes, and include both copying and generated configuration writing in that critical section. Keep the lock until the actual filesystem operation settles even if an awaiting caller is cancelled. Avoid replacing byte-identical files, as already discussed in this issue.

    The small helper below addresses same-process overlapping copies. It is an illustrative integration component, not a complete app patch. Production integration must also consider junction aliases, parent/child destinations, interprocess writers and crash-safe publication of changed plugin versions. It will not solve a genuinely changed file held by a non-delete-sharing Windows handle on its own.

    serialized-copy.mjs
    // Proposed fix for app maintainers. Not installed into the Codex application.
    import fs from 'node:fs/promises';
    import path from 'node:path';
    
    const pendingCopies = new Map();
    
    export function createSerializedCopy(copy = fs.cp) {
      return function serializedCopy(source, destination, options = {}) {
        const resolved = path.resolve(destination);
        const key = process.platform === 'win32' ? resolved.toLowerCase() : resolved;
        const previous = pendingCopies.get(key) ?? Promise.resolve();
        const operation = previous.catch(() => {}).then(() => copy(source, destination, options));
        const tail = operation.catch(() => {});
        pendingCopies.set(key, tail);
        return operation.finally(() => {
          if (pendingCopies.get(key) === tail) pendingCopies.delete(key);
        });
      };
    }
    
    export const serializedCopy = createSerializedCopy();

    Verified locally: twenty serialized copy operations completed without error; manifest and all twenty file contents matched. A failed queued operation did not poison the next one, and different destinations remained concurrent.

    test-serialized-copy.mjs (run with node)
    import assert from 'node:assert/strict';
    import fs from 'node:fs/promises';
    import path from 'node:path';
    import os from 'node:os';
    import { createSerializedCopy, serializedCopy } from './serialized-copy.mjs';
    
    const root = await fs.mkdtemp(path.join(os.tmpdir(), 'codex-copy-fix-test-'));
    const source = path.join(root, 'source');
    await fs.mkdir(path.join(source, '.codex-plugin'), { recursive: true });
    await fs.writeFile(path.join(source, '.codex-plugin', 'plugin.json'), '{"name":"test"}');
    for (let index = 0; index < 20; index++) {
      await fs.writeFile(path.join(source, `file-${index}.txt`), `content-${index}`);
    }
    
    let operations = 0;
    for (let round = 0; round < 10; round++) {
      const destination = path.join(root, `round-${round}`);
      await fs.cp(source, destination, { recursive: true });
      await Promise.all([
        serializedCopy(source, destination, { recursive: true }),
        serializedCopy(source, destination, { recursive: true }),
      ]);
      assert.equal(await fs.readFile(path.join(destination, '.codex-plugin', 'plugin.json'), 'utf8'), '{"name":"test"}');
      for (let index = 0; index < 20; index++) {
        assert.equal(await fs.readFile(path.join(destination, `file-${index}.txt`), 'utf8'), `content-${index}`);
      }
      operations += 2;
    }
    
    // A failed copy must reject its caller without poisoning the queue.
    let attempts = 0;
    const retryCopy = createSerializedCopy(async () => {
      if (++attempts === 1) throw Object.assign(new Error('injected failure'), { code: 'EIO' });
      return 'recovered';
    });
    const destination = path.join(root, 'failure-recovery');
    const results = await Promise.allSettled([retryCopy(source, destination), retryCopy(source, destination)]);
    assert.equal(results[0].status, 'rejected');
    assert.equal(results[1].status, 'fulfilled');
    assert.equal(results[1].value, 'recovered');
    
    // Different destinations should remain independent.
    let active = 0;
    let peak = 0;
    const parallelCopy = createSerializedCopy(async () => {
      peak = Math.max(peak, ++active);
      await new Promise(resolve => setTimeout(resolve, 20));
      active--;
    });
    await Promise.all([parallelCopy(source, path.join(root, 'a')), parallelCopy(source, path.join(root, 'b'))]);
    assert.equal(peak, 2);
    console.log(JSON.stringify({ status: 'PASS', serializedOperations: operations, rounds: 10, verifiedContents: true, errorRecovery: true, distinctDestinationsParallel: true }));

    No claim that this fix is shipped or applied to the installed application. Local Work remains enabled.

    Privacy

    This comment contains only sanitized observations and independently authored synthetic test/candidate code. No usernames, machine names, personal paths, account IDs, task/conversation IDs, conversation contents, credentials, screenshots, raw logs, binaries or extracted proprietary application source are included.

    Report marker: executor-copy-concurrency-26.1016-enoent-eperm.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    appbugskillswindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions