{"record":{"id":"0dd6cfb940685261","repo":"tokio-rs/tokio","slug":"a-tokio-1-x-context-was-found-but-timers-are-disa","errorCode":null,"errorMessage":"A Tokio 1.x context was found, but timers are disabled. Call `enable_time` on the runtime builder to enable timers.","messagePattern":"A Tokio 1\\.x context was found, but timers are disabled\\. Call `enable_time` on the runtime builder to enable timers\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"tokio/src/runtime/driver.rs","lineNumber":115,"sourceCode":"\n    cfg_signal_internal_and_unix! {\n        #[track_caller]\n        pub(crate) fn signal(&self) -> &crate::runtime::signal::Handle {\n            self.signal\n                .as_ref()\n                .expect(\"A Tokio 1.x context was found, but IO is disabled. Call `enable_io` on the runtime builder to enable IO.\")\n        }\n    }\n\n    cfg_time! {\n        /// Returns a reference to the time driver handle.\n        ///\n        /// Panics if no time driver is present.\n        #[track_caller]\n        pub(crate) fn time(&self) -> &crate::runtime::time::Handle {\n            self.time\n                .as_ref()\n                .expect(\"A Tokio 1.x context was found, but timers are disabled. Call `enable_time` on the runtime builder to enable timers.\")\n        }\n\n        #[cfg(tokio_unstable)]\n        pub(crate) fn with_time<F, R>(&self, f: F) -> R\n        where\n            F: FnOnce(Option<&crate::runtime::time::Handle>) -> R,\n        {\n            f(self.time.as_ref())\n        }\n\n        pub(crate) fn clock(&self) -> &Clock {\n            &self.clock\n        }\n    }\n}\n\n// ===== io driver =====\n","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/tokio-rs/tokio/blob/7d0d729d8f03a0033d6752730d0fb5928962560e/tokio/src/runtime/driver.rs#L97-L133","documentation":"Driver::time() calls .expect(...) when self.time is None — the runtime was built without the time driver (no enable_time / not enable_all), yet code uses tokio::time APIs (sleep, interval, timeout).","triggerScenarios":"Calling sleep/interval/timeout on a runtime whose Builder lacks enable_time(); using a minimal Builder for compute then awaiting a timer.","commonSituations":"Custom Builder omitting enable_all; intentionally disabling timers then accidentally calling sleep; test harness with stripped-down runtime.","solutions":["Call .enable_all() (or .enable_time()) on the Builder.","Don't call tokio::time::* on time-disabled runtimes; route timer usage to a full runtime.","Audit Builder config and ensure enable_time when timers are used.","If you truly need no timers, eliminate all sleep/timeout/interval usages in that runtime's scope."],"exampleFix":"// before\nlet rt = Builder::new_current_thread().enable_io().build()?;\nrt.block_on(async { tokio::time::sleep(Duration::from_secs(1)).await; }); // panics\n// after\nlet rt = Builder::new_current_thread().enable_all().build()?;\nrt.block_on(async { tokio::time::sleep(Duration::from_secs(1)).await; });","handlingStrategy":"validation","validationCode":"let rt = tokio::runtime::Builder::new_current_thread()\n    .enable_all() // ensures time driver is on\n    .build()?;","typeGuard":null,"tryCatchPattern":"// Macro panics; manual build surfaces error:\nmatch Builder::new_current_thread().enable_all().build() {\n    Ok(rt) => rt.block_on(async { tokio::time::sleep(...).await }),\n    Err(e) => { eprintln!(\"no time driver: {e}\"); std::process::exit(1); }\n}","preventionTips":["Call enable_all() (or enable_time()) on the Builder.","Never use tokio::time::* on a time-disabled runtime.","Audit Builder configs when isolating compute workloads."],"tags":["runtime","time-driver","builder","panic","configuration"],"backgroundTag":null,"analyzedSha":"7d0d729d8f03a0033d6752730d0fb5928962560e","analyzedAt":"2026-08-11T17:46:45.378Z","contentChangedAt":"2026-08-11T17:46:45.378Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}