codex icon indicating copy to clipboard operation
codex copied to clipboard

Update hangs forever in PackagesInUseClosed: leftover codex-chrome-native-host.exe keeps the old package "in use"

Open ChinningPan opened this issue 1 week ago • 2 comments

Summary

The Microsoft Store update of the ChatGPT / Codex Windows app hangs forever in the PackagesInUseClosed state on my machine, even though the download and staging steps always succeed. The cause is a leftover codex-chrome-native-host.exe — the native messaging host of the ChatGPT browser extension — which keeps the old package's deployment metadata open, so AppX can never satisfy the "no one is using the old package" precondition and cancels the register after ~10 minutes with no visible error in the Store UI.

I believe this is two independent problems that are often conflated:

  • (A) PrimaryRuntime cleanup keeps failing with 0x80073D02 / Failure in the DynamicDependenciesInUse state handler. This matches the behaviour reported in #62596 and #62868, is present on my machine too, but is not user-fixable — it only logs errors and does not by itself block the update.
  • (B) The main app package fails to re-register because of the leftover native messaging host. This one is diagnosable and work-aroundable, and I believe it is the actual reason the update "hangs forever" for many users.

Note the difference between the two: (A) produces error events; (B) produces the hang.

Environment

  • Windows 11 Home (China) x64, DisplayVersion=25H2, build 26200.9457 (registry CurrentBuild=26200.9457)
  • Note: I am not on the two KBs suspected by @mdruy — KB5127936 and KB5132061 are not installed on this machine (no matching WinSxS / CBS rollup package). The only cumulative rollup packages present are 26100.1742.1.10 and 26100.9457.1.0.
  • OpenAI.Codex package family OpenAI.Codex_2p2nqsd0c76g0, Store-signed (SignatureKind=Store), Store ProductId 9PLM9XGG6VKS
  • Subscription: Plus
  • Non-admin user, UAC elevation available

(A) Persisting 0x80073D02 on OpenAI.CodexPrimaryRuntime

Present here as well, but with no 0x8007045B / 0x800706D9 / os error 1008 companions (I searched 14 days of AppXDeploymentServer/Operational, AppModel-Runtime/Admin and System — zero hits for all three). Also worth noting for triage: this machine does not have KB5127936 or KB5132061 installed, and the problem still reproduces.

Current state — multiple PrimaryRuntime versions coexist

OpenAI.CodexPrimaryRuntime.v26-1111-570-0 | 26.1111.570.0 | NotAvailable
OpenAI.CodexPrimaryRuntime.v26-1118-904-0 | 26.1118.904.0 | Ok
OpenAI.CodexPrimaryRuntime.v26-1119-907-0 | 26.1119.907.0 | NotAvailable
OpenAI.CodexPrimaryRuntime.v26-1123-915-0 | 26.1123.915.0 | Ok
OpenAI.Codex                          | 26.1120.5083.0 | Ok

Error volume — last 3 days, AppXDeploymentServer/Operational

total 0x80073D02 events = 40
  id=605 (Failure in the DynamicDependenciesInUse state handler) x19
  id=664 (The request cannot be processed because package ... is in use) x16
  id=404 (AppX Deployment operation failed)                     x5
  package OpenAI.CodexPrimaryRuntime.v26-1119-907-0  x16
  package OpenAI.CodexPrimaryRuntime.v26-1123-915-0  x2

The failure loop is a remove/requeue cycle on every deploy

id=855 Finished resolving action lists. removePackageList: OpenAI.CodexPrimaryRuntime.v26-1119-907-0_...
id=603 Started deployment Remove operation ... Options DeferRemovalWhenPackagesAreInUse
id=664 Error 0x80073D02: The request cannot be processed because package ... is in use.
id=674 Removal of package ... is deferred because it is currently in use.
id=626 Deployment Remove operation ... has been requeued for user SID ...-1001
id=607 Deployment Remove operation ... has been de-queued and is running for user SID ...-1001

Notably id=674 says "Removal ... is deferred because it is currently in use" and id=626 says "has been requeued", i.e. AppX itself decides to keep retrying forever.

Remove-AppxPackage on an idle PrimaryRuntime never returns

This is the part I could not work around. With the app closed and the service stopped, removing a NotAvailable runtime hangs indefinitely:

Remove-AppxPackage -Package OpenAI.CodexPrimaryRuntime.v26-1111-570-0_...  -> TIMEOUT after 90 s, package still present
Remove-AppxPackage -Package OpenAI.CodexPrimaryRuntime.v26-1119-907-0_...  -> TIMEOUT after 90 s, package still present

The Restart Manager API (RmStartSession / RmRegisterResources / RmGetList) reports no process holding any file in those package directories — so it is not a file-handle lock, it is the package-removal path itself hanging.

What does clear the marker

Deleting the stale markers under HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\DeferredRemoval\<SID>\PackageFullNames\ (note: these are child keys, not values) lets the deployment queue drain again and a subsequent register succeeds. This is a workaround, not a fix — the markers come back.

(B) The update hang has a second, separate cause: leftover native messaging host

This is the part that makes the update hang rather than merely log errors, and I don't see it in the reports above.

Symptom

The Store stages the new build fine, then the register step hangs in PackagesInUseClosed and is cancelled after ~10 minutes:

id=603 Started deployment RegisterByPackageFamilyName ... Options ForceTargetApplicationShutdownOption,RegisterHighestVersion,FailIfNeedsRemediation
id=678 Deployment Register operation with main parameter OpenAI.Codex_26.1116.6628.0_x64__2p2nqsd0c76g0
      is hung and cancelled. Failure occurred in the PackagesInUseClosed state handler.
id=615 Deployment Register operation ... has been cancelled by the caller.

The holder

codex-chrome-native-host.exe (the Chrome/Edge native messaging host for the ChatGPT browser extension) stays alive long after the browser tab is gone, holding deployment metadata of the old package under:

C:\ProgramData\Microsoft\Windows\AppRepository\Packages\OpenAI.Codex_<oldversion>_x64__2p2nqsd0c76g0\

Restart Manager on that directory returns the holder(s):

pid=16312 extension-host.exe  (chrome-extension://hehggadaopoacecdllhhajmbjkdcmajg/)
pid=26412 extension-host.exe
pid=27780 extension-host.exe
pid=41212 extension-host.exe

with command lines like:

codex-chrome-native-host.exe chrome-extension://hehggadaopoacecdllhhajmbjkdcmajg/ --parent-window=0

--parent-window=0 means a background service worker started it; it then waits for the native-messaging pipe peer to disappear, which never happens because the worker is gone. On my machine these processes survived 13–25 hours (oldest 11-23 10:45:08, newest 11-23 23:09:27) even though I was not using the extension at all.

Why killing them is not enough

Chrome/Edge re-launch the host immediately when the extension is still installed, so the "old package in use" condition re-arms within seconds. The only reliable way I found is to remove the native-messaging registration for the duration of the update:

HKCU\SOFTWARE\Google\Chrome\NativeMessagingHosts\com.openai.codexextension
  -> C:\Users\<user>\AppData\Local\OpenAI\extension\com.openai.codexextension.json

The manifest's path is an alias resolved by package family name:

"path": "C:\\Users\\<user>\\AppData\\Local\\Microsoft\\WindowsApps\\OpenAI.Codex_2p2nqsd0c76g0\\codex-chrome-native-host.exe"

so it always launches from whatever version is currently registered — meaning the host is guaranteed to hold the old package during an update. I believe this alias is the underlying design issue (see also the Chrome-plugin packaging discussion in #32706): the Store's ForceTargetApplicationShutdownOption only closes the app's main window, and it cannot touch a browser-spawned native host or a system service, so the update waits out the full timeout and cancels.

The successful sequence I used (for reference)

  1. Delete HKCU\...\NativeMessagingHosts\com.openai.codexextension and rename the manifest .json → .json.disabled (the registry key is re-created spontaneously by the browser extension / app itself, so a single measure is not enough).
  2. Stop CodexSandboxService.OpenAI.Codex (it is Automatic and gets reinstalled with Start=2 on every package install, so it must be stopped for the duration).
  3. Kill all extension-host.exe and ChatGPT.exe.
  4. Optionally disable WSAIFabricSvc (HKLM\SYSTEM\CurrentControlSet\Services\WSAIFabricSvc\Start=4) — it otherwise re-locks the new package payload directory and it auto-restarts.
  5. Sanity-check that the AppX deployment queue is healthy by re-registering an unrelated healthy package in place (e.g. Microsoft.Winget.Source via Add-AppxPackage -Register ...\AppxManifest.xml). If that completes in a few seconds, the queue is not blocked.
  6. Register the new build: Add-AppxPackage -Register <new>\AppxManifest.xml -DisableDevelopmentMode -ForceApplicationShutdown.

Result on my machine: 26.1111.9664.0 → 26.1117.4957.0 → 26.1120.5083.0, all three transitions completing in seconds-to-minutes with id=400 ... finished successfully, no reboot required.

Reproduction rate before the workaround

Every Store-driven update attempt in this cycle failed the same way (id=678, PackagesInUseClosed), across versions 26.1103.7773.0 → 26.1106.6628.0 → 26.1111.2228.0 → 26.1111.9664.0 → 26.1120.5083.0.

Additional notes

  • The app's own in-app updater (CallerApplicationId: ChatGPT-SearchForUpdatesWithPausedAddAsync) triggers the same path, so the failure also occurs without touching the Store UI.
  • The Store UI itself failed to launch in my environment (TWinUI/Operational → id=5961 Activation for Microsoft.WindowsStore_...!App failed. Error code: The app didn't start in the required time.. Activation phase: COM App activation, plus 0x80040905), so I had to drive the install through Windows.ApplicationModel.Store.Preview.InstallControl.AppInstallManager → SearchForUpdatesAsync(productId, skuId). This may be unrelated, but it is reproducible here on Store build 22609.1401.13.0.
  • Remove-AppxPackage on the NotAvailable runtimes never completes (see above), so uninstall/reinstall of the runtime packages is not a usable workaround.
  • Uninstalling and reinstalling the app does not help for (A): the PrimaryRuntime errors reappear immediately.

What would help

  1. Confirm whether the PrimaryRuntime 0x80073D02 loop is a known Windows/AppX regression (it reproduces on a build that has neither KB5127936 nor KB5132061 installed here, so it may predate those updates or have another trigger).
  2. Consider making the ChatGPT browser extension's native messaging host not hold the registered package open — e.g. resolve the host binary from a fixed, version-independent location, or have the Store's update flow signal the host to exit (like ForceTargetApplicationShutdownOption does for the app).
  3. Ideally the PrimaryRuntime packages would be superseded/removed by the same deployment operation that installs the new one, instead of leaving NotAvailable markers that are then retried forever.

Happy to provide additional logs (full AppXDeploymentServer/Operational excerpts, Restart Manager output, or a repro script) if useful.

ChinningPan avatar Nov 24 '26 08:11 ChinningPan

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

  • #62596
  • #62868

Powered by Codex Action

github-actions[bot] avatar Nov 24 '26 08:11 github-actions[bot]

Related evidence for the framework-cleanup side of this report. On Windows 11 26H2 build 26300.10075 with desktop MSIX 26.1120.6357.0 and Primary Runtime 26.1123.915.0, I saw 0x80073D02 when App Readiness and ChatGPT.exe requested removal of the framework. The app logged framework activation followed by a deferred-removal request around launch. The process tree later showed a ChatGPT node.exe and a Codex pwsh.exe running directly out of the framework folder.

My capture concerns the Primary Runtime removal, and does not establish that the Chrome native host held the old desktop package or that the updater stalled in PackagesInUseClosed on this PC. It may help to document exactly which package each dependency or leftover process keeps in use. I put the matching AppX evidence and version details in #62868.

mdruy avatar Nov 25 '26 18:11 mdruy