Skip to content

fix(app-server): SpawnedCodexAppServerClient.initialize is unbounded (same hang class as #29) #31

Closed

Description

@axisrow

Problem

BrokerCodexAppServerClient.initialize got bounded handshake timeouts in #30 (connect 2s + initialize 5s, EBROKERTIMEOUT → direct fallback). Its sibling SpawnedCodexAppServerClient.initialize has the same unbounded shape and was left out of scope there.

plugins/codex/scripts/lib/app-server.mjs:

```js
// SpawnedCodexAppServerClient.initialize — no deadline
await this.request("initialize", {
clientInfo: this.options.clientInfo ?? DEFAULT_CLIENT_INFO,
capabilities: this.options.capabilities ?? DEFAULT_CAPABILITIES
});
```

If a spawned codex app-server child accepts stdin and then stalls before answering initialize (slow auth check, cold model-provider bootstrap, Windows PATH stall), the client hangs forever — the same failure class #30 closed on the broker path, just on the direct path.

This also weakens the #30 fallback: when withAppServer retries direct after a broker-handshake timeout, the retry itself has no initialize deadline.

Proposed fix (deeper than #30)

Put an optional timeoutMs on AppServerClientBase.request() (default undefined — no deadline, backward compatible), wired from both initialize() overrides and from captureTurn's startRequest. Then:

  • BrokerCodexAppServerClient.initialize drops its inline Promise.race (~40 lines) and calls this.request(\"initialize\", {...}, { timeoutMs }).
  • SpawnedCodexAppServerClient.initialize gets the bound for free.
  • The withAppServer OR-chain (BROKER_BUSY_RPC_CODE || EBROKERTIMEOUT || ENOENT || ECONNREFUSED) collapses to a single broker-transport-error predicate by tagging broker-fatal errors at their source.

TDD

Reproduce first: drive SpawnedCodexAppServerClient.initialize against a fake codex app-server that accepts stdin but never answers initialize, race against a watchdog → today it hangs. Then bound it.

Context

Refs #29, #30, openai#509.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions