microsoft/aspire · error · Win32Exception

Failed to configure CLI kill-on-parent-exit job object…

Error message

Failed to configure CLI kill-on-parent-exit job object limits

What it means

The Aspire CLI creates a Windows Job Object (WindowsConsoleProcessJob) with JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE so child processes die when the CLI exits. This error is thrown when the native SetInformationJobObject call that applies those limits (KILL_ON_JOB_CLOSE + BREAKAWAY_OK) returns false. It wraps the last Win32 error, so the inner message names the underlying OS failure code.

Solutions

  1. Read the inner Win32Exception to identify the native error code (e.g. ERROR_ACCESS_DENIED) and check whether antivirus/EDR or a CI sandbox is blocking Job Object APIs.
  2. If running inside a CI/agent job that already places the process in a restrictive job, run the CLI outside that job or add breakaway permissions.
  3. Retry after a reboot/update of Windows; a corrupted kernel state is rare but possible.
  4. As a last resort run the CLI with killOnParentExit disabled (accepting orphaned child processes) if the code path allows it.
Defensive patterns

Strategy: try-catch

Try / catch

try
{
    var job = WindowsConsoleProcessJob.Shared;
}
catch (Win32Exception ex)
{
    logger.LogError(ex, "Job object limits could not be set (Win32 error {Code}). Falling back to watchdog-only cleanup.", ex.ErrorCode);
}

Prevention

When it happens

Trigger: Constructing WindowsConsoleProcessJob (e.g. via WindowsConsoleProcessJob.Shared on first access when a process is started with killOnParentExit: true) on Windows where SetInformationJobObject(JobObjectExtendedLimitInformation) fails for the freshly created job handle.

Common situations: Corrupted or hardened OS images restricting Job Object APIs; security/EDR software blocking job-object manipulation; running in restricted job sandboxes (CI containers, some CI runners nest processes in jobs with JOB_OBJECT_LIMIT_SILENT_BREAKAWAY restrictions); extremely rare kernel/memory pressure causing marshalling or native-call failure.

Related errors


AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16). Data as JSON: /api/errors/60cab00029883a24. Report an issue: GitHub.

Appendix: source

Thrown at src/Aspire.Cli/Processes/WindowsConsoleProcessJob.cs:97

                {
                    LimitFlags = WindowsProcessInterop.JobObjectLimitKillOnJobClose
                                 | WindowsProcessInterop.JobObjectLimitBreakawayOk,
                },
            };

            var infoSize = Marshal.SizeOf<WindowsProcessInterop.JOBOBJECT_EXTENDED_LIMIT_INFORMATION>();
            var infoPtr = Marshal.AllocHGlobal(infoSize);
            try
            {
                Marshal.StructureToPtr(info, infoPtr, fDeleteOld: false);

                if (!WindowsProcessInterop.SetInformationJobObject(
                    _jobHandle,
                    WindowsProcessInterop.JobObjectInfoClass.ExtendedLimitInformation,
                    infoPtr,
                    (uint)infoSize))
                {
                    throw new Win32Exception(Marshal.GetLastWin32Error(), "Failed to configure CLI kill-on-parent-exit job object limits");
                }
            }
            finally
            {
                Marshal.FreeHGlobal(infoPtr);
            }
        }
        catch
        {
            // Constructor failure must not leave the partial job alive; closing the handle
            // would also fire KILL_ON_JOB_CLOSE harmlessly (zero processes assigned yet) but
            // mainly we just don't want to leak a kernel object.
            _jobHandle.Dispose();
            throw;
        }
    }

    /// <summary>

View on GitHub (pinned to 25830f84bd)