t3code icon indicating copy to clipboard operation
t3code copied to clipboard

[Bug]: Provider updates can race provider launches and text generation

Open nima20002000 opened this issue 3 weeks ago • 0 comments

Before submitting

  • [x] I searched existing issues and did not find a duplicate.
  • [x] I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

Source-derived and timing-dependent; not reproduced at runtime.

  1. Configure an outdated npm-installed Codex provider, also used for text generation.
  2. Start its one-click update (Settings, or the chat's Update action).
  3. While the installer is replacing package files, send a prompt in a new thread (a fresh provider process) or request a generated commit message / title.
  4. The launch or codex exec runs while the updater is modifying the same installation.

A deterministic fixture: pause the installer after it makes the CLI entry point unavailable, then attempt the provider launch / generation before letting the install finish.

Expected behavior

Installation mutation and execution using that installation are coordinated: an update of an in-use provider waits or is refused, and new execution during the mutation waits or gets a clear "updating" error.

Actual behavior

The maintenance coordinator's lock serializes updates only (providerMaintenanceCommandCoordinator.ts:17–52); turn launches and text-generation subprocesses never take part. The runner's checks before executing (providerMaintenanceRunner.ts:440–535) don't look at active or starting work, and updateState doesn't affect availability (ProviderRegistry.ts:464–476, isProviderAvailable in packages/contracts/src/server.ts:274–275). So:

  • TextGeneration.generate invokes the provider with no maintenance check (TextGeneration.ts:125–127); Codex generation then spawns codex exec (CodexTextGeneration.ts:259–345), Claude similarly (ClaudeTextGeneration.ts:202–248).
  • Opening a new provider session spawns the configured binary with no update check (ProviderSessionManager.ts:2120–2183, CodexAdapterV2.ts:1571–1594).

A launch during the replacement step can fail ("Provider session failed to open", a failed commit-message generation, a title left unchanged after retries), while the update itself reports success.

Impact

Minor bug or occasional failure

Version or commit

main @ 9e85538535

Environment

Any; most likely with package-manager installs, several clients, new threads and automatic titles. Native installers that replace atomically may not hit it.


Found by reading the code while maintaining a fork that holds new work during binary swaps; derived from the code at 9e85538535, not reproduced at runtime. A possible shape for a fix: one server-side admission shared by execution that uses an installation and the update that mutates it (refuse/defer the update while that installation is in use; make new execution wait or fail clearly during the mutation), covering pending launches and text generation through subprocess exit.

nima20002000 avatar Nov 04 '26 21:11 nima20002000