Skip to content

Windows sandbox: npm test fails and node --test hangs inside the AppContainer #101

Open

Description

@PierrunoYT

Problem

Inside the Windows AppContainer sandbox (sandbox-helper.exe), the standard Node.js test commands do not work:

  • npm test and npm.cmd test exit with code 1.
  • node --test (with no arguments, with a folder, or with a single file) hangs until the command times out.

This happened in every run that tried these commands during the plan-mode benchmark on 2026-10-05: 24 runs on two builds, Claude Sonnet 5.5, small projects whose package.json has "test": "node --test" and that need no dependencies. The model then tried variations (cmd /c npm test, --test-isolation=none), so each run took 150–200 s instead of about 15 s. The benchmark's own check ran the same tests unsandboxed and they passed, so the projects themselves were fine.

Failed calls recorded by the benchmark (toolsByName / failedTools in out/bench-agent-tasks-plan.json):

run_command: Ran `npm test` (exit 1)
run_command: Ran `npm.cmd test` (exit 1)
run_command: Ran `node --test` (timed out)
run_command: Ran `node --test test/strings.test.js` (timed out)
run_command: Ran `node --test --test-isolation=none test/strings.test.js` (exit 1)

The helper source is the same on main (37f8bb6) and in PR #92, and both builds behaved the same way.

Possible causes to check

  • npm needs folders under the user profile that the AppContainer cannot reach (%APPDATA%\npm-cache, %LOCALAPPDATA%\npm-cache, .npmrc), and the home folder is hidden.
  • TEMP/TMP point to %LOCALAPPDATA%\Temp, which is not granted. The Windows policy grants no temporary folder, unlike the other backends (see also security: narrow macOS sandbox file access and isolate command temp directories #96 for macOS).
  • node --test starts a child process for each test file and talks to it over pipes. Check whether creating those pipes fails or blocks under the AppContainer token or the job object's limits.

Use the existing Vitest integration tests (sandbox_windows.integration.test.ts) or focused instrumentation in the helper to find out. Do not launch the helper through nested PowerShell with redirected stdin (see AGENTS.md).

Acceptance checks

  • A real Windows integration test runs npm test and node --test on a dependency-free fixture project inside the sandbox, and both pass.
  • Any temporary folder or cache granted for this is per command (or limited to the project) and does not expose the rest of the profile.

Activity

  1. added
    bugSomething isn't working
    priority: highDo soon: broad impact or blocks other work
    on Oct 5, 2026
  2. stepupgaming commented on Oct 5, 2026

    @stepupgaming
    Collaborator

    On this machine the failure is earlier than a hang. C:\Program Files\nodejs has no ALL APPLICATION PACKAGES ACE, and windowsPolicy does not grant Program Files, so node and npm are not visible at all. Details are in #106. The hang described here can still show up once the binary is readable.

  3. PierrunoYT commented on Oct 7, 2026

    @PierrunoYT
    OwnerAuthor

    Status: blocked upstream. The Patch side is done. What's left needs a Node.js release that bundles libuv ≥ 1.53, and none does yet.

    Cause

    In libuv ≤ 1.52.1, uv__unique_pipe_name names every child-process stdio pipe \\?\pipe\uv\<n>-<pid>. An AppContainer may only create named pipes under \\.\pipe\LOCAL\… (see the CreateNamedPipe remarks), so CreateNamedPipeA fails with ERROR_ACCESS_DENIED. uv__pipe_server treats that error as a name collision, increments the name and retries forever. That's why node --test (one child process per test file) hangs until the command timeout instead of failing. The same applies to any sandboxed Node program that spawns children with piped stdio.

    Upstream status (checked 2026-10-07)

    • The fix is libuv#5181, released in libuv 1.53.0. It detects AppContainer with TokenIsAppContainer and adds LOCAL\ to the pipe name.
    • Node.js main, v26.x and v24.x (since 24.16) bundle libuv 1.52.1. v22.x bundles 1.51.0. I found no Node release and no open update PR with 1.53.

    Why Patch can't work around it

    • No capability: Windows has no capability that allows pipe creation outside LOCAL\. Compiler Explorer hit the same limit (ninja#2354).
    • Pre-creating doesn't help: if the helper created the pipe first, libuv's create would still fail with ERROR_ACCESS_DENIED and keep looping.
    • Ruled out: hooking node.exe to rename the pipes, shipping a patched Node, or adding --test-isolation=none to commands automatically.

    What is done

    • 3ac2d97: private per-command temp folder, npm cache and empty npm user config; project PATH entries use the mapped drive; process-only PowerShell execution policy. npm test, npm.cmd test and node --test pass with --test-isolation=none in the real Windows integration tests.
    • 1311572: when a command in the Windows AppContainer times out, the run_command result tells the agent why. It names --test-isolation=none (--experimental-test-isolation=none on Node 22) and the unsandboxed request. The command is never rewritten. This targets the 150–200 s benchmark runs where the model retried variations blindly.

    To close this issue

    Once a Node release bundles libuv ≥ 1.53, run sandbox_windows.integration.test.ts on that runtime. Its default-isolation node --test / npm test checks stop skipping on libuv ≥ 1.53, and they cover the first acceptance check. The timeout hint can be removed once the minimum supported Node includes the fix.

  4. PierrunoYT commented on Oct 9, 2026

    @PierrunoYT
    OwnerAuthor

    Upstream status (2026-10-09): libuv 1.53.0 was released on 2026-09-24, and Node.js has an open automated PR to adopt it, nodejs/node#66282 (opened 2026-09-25, not merged yet; deps/uv on main is still 1.52.1). Once a Node.js release ships it, re-run the Windows sandbox integration tests for default node --test and drop the test-isolation=none hint if they pass. Notes: docs/WINDOWS_SANDBOX_RESEARCH.md.

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

    bugSomething isn't workingplatform: windowsAffects only Windowspriority: highDo soon: broad impact or blocks other workseverity: mediumAudit severity: medium

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions