{"record":{"id":"4fd731927a10aba4","repo":"GraphiteEditor/Graphite","slug":"failed-to-construct-async-message-tokio-runtime","errorCode":null,"errorMessage":"failed to construct async-message tokio runtime","messagePattern":"failed to construct async-message tokio runtime","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"editor/src/messages/future/future_message_handler.rs","lineNumber":175,"sourceCode":"}\n\n#[cfg(not(target_family = \"wasm\"))]\nimpl Default for TokioSpawner {\n\tfn default() -> Self {\n\t\tSelf { runtime: std::sync::OnceLock::new() }\n\t}\n}\n\n#[cfg(not(target_family = \"wasm\"))]\nimpl TokioSpawner {\n\tfn runtime(&self) -> &tokio::runtime::Runtime {\n\t\tself.runtime.get_or_init(|| {\n\t\t\ttokio::runtime::Builder::new_multi_thread()\n\t\t\t\t.worker_threads(1)\n\t\t\t\t.thread_name(\"graphite-async\")\n\t\t\t\t.enable_all()\n\t\t\t\t.build()\n\t\t\t\t.expect(\"failed to construct async-message tokio runtime\")\n\t\t})\n\t}\n}\n\n#[cfg(not(target_family = \"wasm\"))]\nimpl MessageSpawner for TokioSpawner {\n\tfn spawn(&self, future: InnerMessageFuture, results: UnboundedSender<Message>, wake: Wake) {\n\t\tself.runtime().spawn(async move {\n\t\t\tlet message = future.await;\n\t\t\tlet _ = results.unbounded_send(message);\n\t\t\twake();\n\t\t});\n\t}\n}\n\n#[cfg(target_family = \"wasm\")]\nstruct WasmSpawner;\n","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/GraphiteEditor/Graphite/blob/c507b356453361e31638b8bff8f6d46b6da2961e/editor/src/messages/future/future_message_handler.rs#L157-L193","documentation":"Panic when tokio::runtime::Builder::new_multi_thread().worker_threads(1).enable_all().build() returns an Err inside TokioSpawner, the editor's async-message executor. The multi-thread runtime build fails when the OS cannot create the worker thread (thread limits, memory), or — more commonly on Linux — when enable_all's I/O driver cannot be set up because epoll_create1/timerfd_create fail (fd exhaustion or a seccomp sandbox blocking those syscalls).","triggerScenarios":"Constructing the editor's async spawner in a process at its fd or thread limit; running under a strict seccomp/container profile that blocks epoll or timerfd syscalls; severe memory pressure preventing the worker thread's stack allocation.","commonSituations":"Embedding the editor crate inside sandboxed executors (gVisor, firecracker, restricted gVisor-like runtimes) that block the I/O driver syscalls; apps that exhaust file descriptors before spawning async work; test harnesses with low rlimits.","solutions":["Raise fd and thread limits for the host process (ulimit -n, ulimit -u, container limits)","If sandboxed, allow epoll_create1, epoll_ctl, epoll_wait and timerfd_create syscalls in the security profile","Check /proc/<pid>/fd counts and thread counts to identify exhaustion","Reduce the number of concurrently running runtimes if the host creates many TokioSpawners"],"exampleFix":"// before\n.build()\n.expect(\"failed to construct async-message tokio runtime\")\n\n// after\n.build()\n.unwrap_or_else(|e| panic!(\"failed to construct async-message tokio runtime: {e}\"))","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"let runtime = tokio::runtime::Builder::new_multi_thread()\n\t.worker_threads(1)\n\t.thread_name(\"graphite-async\")\n\t.enable_all()\n\t.build();\nlet runtime = match runtime {\n\tOk(rt) => rt,\n\tErr(e) => panic!(\"failed to construct async-message tokio runtime: {e} (check thread/fd limits and sandbox syscalls)\"),\n};","preventionTips":["Ensure host processes embedding the editor have adequate thread and fd limits","In sandboxed runtimes, permit epoll_create1/epoll_ctl/epoll_wait and timerfd_create syscalls","Construct the spawner's runtime lazily and once, so repeated message spawns cannot stack runtimes"],"tags":["rust","tokio","async","os-limits","runtime-initialization"],"backgroundTag":"tokio-runtime-build-failed","analyzedSha":"c507b356453361e31638b8bff8f6d46b6da2961e","analyzedAt":"2026-08-16T21:57:18.596Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}