{"record":{"id":"dfcafe02d07277d2","repo":"nautechsystems/nautilus_trader","slug":"lighter-inactive-order-lookup-exceeded-max-reconc","errorCode":null,"errorMessage":"Lighter inactive-order lookup exceeded {MAX_RECONCILIATION_PAGES} pages","messagePattern":"Lighter inactive-order lookup exceeded (.+?) pages","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/lighter/src/websocket/dispatch.rs","lineNumber":1906,"sourceCode":"\n    if let Some(order) = active_match {\n        return finalize(order).map(Some);\n    }\n\n    if target_venue_index.is_none() {\n        return Ok(None);\n    }\n\n    // Fall back to inactive orders (filled / canceled). Pagination is followed\n    // because a single market can hold more than 200 historical inactive\n    // orders for a long-running account.\n    let mut cursor: Option<String> = None;\n    let mut seen_cursors = AHashSet::new();\n    let mut pages = 0_usize;\n\n    loop {\n        pages += 1;\n        anyhow::ensure!(\n            pages <= MAX_RECONCILIATION_PAGES,\n            \"Lighter inactive-order lookup exceeded {MAX_RECONCILIATION_PAGES} pages\",\n        );\n        let query = Zeroizing::new(LighterAccountInactiveOrdersQuery {\n            authorization: None,\n            auth: Some(auth.clone()),\n            account_index: credential.account_index(),\n            market_id: Some(market_index),\n            ask_filter: None,\n            between_timestamps: None,\n            cursor: cursor.clone(),\n            limit: LIGHTER_REST_PAGE_SIZE,\n        });\n        let inactive = http_client\n            .get_account_inactive_orders(&query)\n            .await\n            .context(\"failed to fetch Lighter inactive orders\")?;\n","sourceCodeStart":1888,"sourceCodeEnd":1924,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/lighter/src/websocket/dispatch.rs#L1888-L1924","documentation":"The inactive (historical) orders endpoint is paginated, and the lookup caps pagination at MAX_RECONCILIATION_PAGES to bound latency and API usage. Exceeding the cap aborts the lookup rather than scanning the venue's full order history.","triggerScenarios":"Looking up an order that is not in active orders and whose history is deep enough that the pagination cursor walks more than MAX_RECONCILIATION_PAGES pages without finding it.","commonSituations":"High-frequency accounts with very large closed-order histories; searching for an old order with only a client_order_id; time-range filters absent, forcing full-history scans.","solutions":["Narrow the lookup using a venue_order_id or tighter query window so the target order is found in fewer pages.","Raise MAX_RECONCILIATION_PAGES if your account legitimately needs deeper history scans.","Query the order directly by order_index via the REST API instead of paginating history."],"exampleFix":"// before: full-history walk\nlookup_order(Some(&coid), None, ...)\n// after: search with explicit venue order id\nlookup_order(Some(&coid), Some(&venue_order_id), ...)","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"match lookup { Err(e) if e.to_string().contains(\"exceeded\") => { /* fall back to direct REST query by order_index */ }, r => r? }","preventionTips":["Query with a venue_order_id when available","Keep reconciliation order lookups recent (avoid deep history scans)","Tune MAX_RECONCILIATION_PAGES only if legitimately needed"],"tags":["rest","pagination","reconciliation"],"backgroundTag":"value-out-of-range","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"}