openai/codex · error · ReadinessError

TokenLockFailed

TokenLockFailed

Error message

Failed to acquire readiness token lock

What it means

ReadinessError::TokenLockFailed, a thiserror-defined variant in the readiness crate. It fires when the internal lock guarding a readiness token/flag cannot be acquired, typically because the lock was poisoned by a panic in another thread while it was held.

Solutions

  1. Inspect for panics in other threads that hold the token lock; fix the panicking code to avoid poisoning
  2. Recover by reconstructing the readiness token/flag state if the lock is poisoned
  3. Use lock access patterns that avoid holding the guard across fallible or panicking operations
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at codex-rs/utils/readiness/src/lib.rs:194 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/ef0976b7ae832cef. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/utils/readiness/src/lib.rs:194

        // Fast-path check before awaiting.
        if *rx.borrow() {
            return;
        }
        // Await changes until true is observed.
        while rx.changed().await.is_ok() {
            if *rx.borrow() {
                break;
            }
        }
    }
}

mod errors {
    use thiserror::Error;

    #[derive(Debug, Error)]
    pub enum ReadinessError {
        #[error("Failed to acquire readiness token lock")]
        TokenLockFailed,
        #[error("Flag is already ready. Impossible to subscribe")]
        FlagAlreadyReady,
    }
}

#[cfg(test)]
mod tests {
    use std::sync::Arc;
    use std::sync::atomic::Ordering;

    use super::Readiness;
    use super::ReadinessFlag;
    use super::Token;
    use super::errors::ReadinessError;
    use assert_matches::assert_matches;

    #[tokio::test]

View on GitHub (pinned to 339751715c)