{"record":{"id":"ce5512556c32fc54","repo":"nautechsystems/nautilus_trader","slug":"a-transaction-is-being-prepared-at-most-one-tr","errorCode":null,"errorMessage":"A {} transaction is being prepared; at most one transaction can be in flight","messagePattern":"A (.+?) transaction is being prepared; at most one transaction can be in flight","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/execution/client.rs","lineNumber":1851,"sourceCode":"    finalized_headers: Vec<ExecutionVerifiedHeader>,\n}\n\n#[derive(Debug, Clone, Copy)]\nenum TransactionAuthorization {\n    Wrap {\n        weth: Address,\n    },\n    Approve {\n        token: Address,\n        router: Address,\n        amount: U256,\n    },\n}\n\n/// The single-in-flight limit error naming the transaction currently occupying the slot.\nfn in_flight_limit_error(slot: &InFlightSlot) -> anyhow::Error {\n    match slot {\n        InFlightSlot::Preparing(purpose) => anyhow::anyhow!(\n            \"A {} transaction is being prepared; at most one transaction can be in flight\",\n            purpose.as_str()\n        ),\n        InFlightSlot::Recovering(recovery) => anyhow::anyhow!(\n            \"Execution intent {} ({}, nonce {}) retains signer ownership pending recovery; at most one transaction can be in flight\",\n            recovery.intent_id,\n            recovery.purpose.as_str(),\n            recovery.nonce\n        ),\n        InFlightSlot::AwaitingFinality(in_flight) => anyhow::anyhow!(\n            \"Transaction {} (intent {}, {}, nonce {}) is still awaiting finality; at most one transaction can be in flight\",\n            in_flight.tx_hash,\n            in_flight.intent_id,\n            in_flight.purpose.as_str(),\n            in_flight.nonce\n        ),\n    }\n}","sourceCodeStart":1833,"sourceCodeEnd":1869,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/execution/client.rs#L1833-L1869","documentation":"The execution client enforces a strict single-transaction-in-flight model. This error is raised when a new transaction is attempted while the in-flight slot is occupied by a transaction still in the 'Preparing' phase; the message names the purpose currently preparing.","triggerScenarios":"Calling submit_order (or any operation needing the slot) while a previous swap/wrap/approve transaction is still being prepared and has not completed or released the slot.","commonSituations":"Submitting orders too fast from a strategy loop; a prior preparation blocked on a slow RPC call holding the slot; concurrent threads sharing one client without synchronization.","solutions":["Wait for the in-flight transaction to finish (poll its state or await completion) before submitting the next one.","Serialize submissions: queue orders and process one at a time, or use one client per strategy thread.","Recover the stuck preparation — if it never completes, use the recovery path to release the slot.","Check RPC latency; slow eth_* calls extend the preparing window and increase collisions."],"exampleFix":"// before: overlapping submissions\nclient.submit_order(order_a)?;\nclient.submit_order(order_b)?; // slot still held by a\n// after: await completion first\nclient.submit_order(order_a)?;\nclient.await_in_flight_complete().await?;\nclient.submit_order(order_b)?;","handlingStrategy":"retry","validationCode":"if client.in_flight_slot_occupied() { queue_order(order); return; }","typeGuard":null,"tryCatchPattern":"match client.submit_order(order) { Err(e) if e.to_string().contains(\"at most one transaction can be in flight\") => { wait_for_slot().await; retry(order); } Ok(r) => r }","preventionTips":["Serialize order submissions through a queue","Await completion of each transaction before the next submission","Avoid sharing one client across concurrent threads"],"tags":["concurrency","transaction","state-machine"],"backgroundTag":"invalid-state-transition","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}