{"record":{"id":"f5d40ba6ca3f768c","repo":"nautechsystems/nautilus_trader","slug":"timer-name-stop-time-is-in-the-past-curren","errorCode":null,"errorMessage":"Timer '{name}' stop time {} is in the past (current time is {ts_now})","messagePattern":"Timer '(.+?)' stop time (.+?) is in the past \\(current time is (.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/common/src/clock.rs","lineNumber":878,"sourceCode":"\n    if !allow_past && next_event_time < ts_now {\n        anyhow::bail!(\n            \"Timer '{name}' next event time {} would be in the past (current time is {ts_now})\",\n            next_event_time.to_rfc3339(),\n        );\n    }\n\n    if let Some(stop_time) = stop_time_ns {\n        if stop_time <= start_time_ns {\n            anyhow::bail!(\n                \"Timer '{name}' stop time {} must be after start time {}\",\n                stop_time.to_rfc3339(),\n                start_time_ns.to_rfc3339(),\n            );\n        }\n\n        if !allow_past && stop_time <= ts_now {\n            anyhow::bail!(\n                \"Timer '{name}' stop time {} is in the past (current time is {ts_now})\",\n                stop_time.to_rfc3339(),\n            );\n        }\n    }\n\n    Ok((\n        name,\n        start_time_ns,\n        stop_time_ns,\n        allow_past,\n        fire_immediately,\n    ))\n}\n\n/// A deterministic clock for controlled time advancement.\n///\n/// The clock stores a manual timestamp, schedules [`TestTimer`] instances, and returns due events","sourceCodeStart":860,"sourceCodeEnd":896,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/common/src/clock.rs#L860-L896","documentation":"When a stop_time_ns is supplied, set_timer_ns also requires it to be in the future (unless allow_past is set). A stop time already in the past means the timer would be born already expired, so the request is rejected rather than registering a useless timer.","triggerScenarios":"Calling set_timer_ns with Some(stop_time_ns) <= clock.timestamp_ns() while allow_past is false.","commonSituations":"Session end times persisted from a previous run and reused; long-running deployment crossing the configured daily/weekly stop time; clock skew; seconds-vs-nanoseconds conversion mistakes making the value tiny and thus 'past'.","solutions":["Recompute stop_time_ns relative to the current clock time before registering the timer.","Skip timer registration entirely if the scheduled stop time has already passed (the timer's work window is over).","Enable allow_past if immediate expiry / past semantics are acceptable.","Guard in caller code: if stop_time_ns <= clock.timestamp_ns() { return; } before calling set_timer_ns."],"exampleFix":"// before\nclock.set_timer_ns(\"session_timer\", interval_ns, start, Some(saved_stop_ns), None, false, false);\n// after\nlet now = clock.timestamp_ns();\nif saved_stop_ns > now {\n    clock.set_timer_ns(\"session_timer\", interval_ns, start, Some(saved_stop_ns), None, false, false);\n}","handlingStrategy":"validation","validationCode":"fn ensure_future_stop(clock: &dyn Clock, stop_time_ns: Option<u64>) -> anyhow::Result<()> {\n    if let Some(stop) = stop_time_ns {\n        anyhow::ensure!(stop > clock.timestamp_ns(), \"stop {stop} already in the past\");\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":"match clock.set_timer_ns(name, interval_ns, start, stop, None, false, false) {\n    Err(e) if e.to_string().contains(\"stop time\") && e.to_string().contains(\"in the past\") => {\n        log::warn!(\"session window already closed, skipping timer\");\n    }\n    other => other?,\n}","preventionTips":["Recompute session stop times at every startup instead of persisting them","Skip timer registration when the stop deadline has passed","Guard against seconds-vs-nanoseconds mistakes (tiny values look 'past')","Be explicit about allow_past semantics before relying on past stop times"],"tags":["timer","clock","validation","time"],"backgroundTag":"invalid-argument-value","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"}