mirror of
https://github.com/openai/codex.git
synced 2026-10-22 17:58:46 +00:00
## Why
Graceful shutdown rejects new sessions with an invalid-request error. Give clients a structured shutdown reason and show command center users why session creation is paused.
## What changed
- Add `data: {"reason":"serverShuttingDown"}` to app-server shutdown admission errors while retaining JSON-RPC code `-32600`.
- Show a dedicated shutdown message explaining the wait for active turns and automatic reconnection for non-embedded servers. Recognize older servers by their exact draining message only when error data is absent, and preserve retained-worktree cleanup guidance.
- Keep the command center reconnect presentation when a shutdown error covers the initial overview and no conversation is open.
## Testing
Extend admission and WebSocket shutdown assertions, add embedded and daemon shutdown message snapshots, and cover reconnection with a shutdown error over the initial command center.
GitOrigin-RevId: f167144c0ddc77872afdf3daac8bb1c89f3425b4
29 lines
976 B
Rust
29 lines
976 B
Rust
use super::TurnAdmission;
|
|
use crate::error_code::INVALID_REQUEST_ERROR_CODE;
|
|
use codex_extension_api::TurnStartAdmission;
|
|
use pretty_assertions::assert_eq;
|
|
|
|
#[test]
|
|
fn drain_rejects_new_work_without_waiting_for_admitted_work() {
|
|
let admission = TurnAdmission::default();
|
|
let active = admission.subscribe_active();
|
|
let in_flight = admission.admit().expect("initial request admitted");
|
|
let automatic = admission
|
|
.admit_turn_start()
|
|
.expect("automatic start admitted");
|
|
admission.begin_drain();
|
|
assert_eq!(*active.borrow(), 2);
|
|
assert!(admission.admit_turn_start().is_none());
|
|
|
|
let error = admission.admit().err().expect("new request rejected");
|
|
assert_eq!(error.code, INVALID_REQUEST_ERROR_CODE);
|
|
assert_eq!(
|
|
error.data,
|
|
Some(serde_json::json!({ "reason": "serverShuttingDown" }))
|
|
);
|
|
drop(in_flight);
|
|
assert_eq!(*active.borrow(), 1);
|
|
drop(automatic);
|
|
assert_eq!(*active.borrow(), 0);
|
|
}
|