{"record":{"id":"0352aea55433f4c0","repo":"swc-project/swc","slug":"failed-to-create-shared-tokio-runtime-for-plugin-e","errorCode":null,"errorMessage":"Failed to create shared tokio runtime for plugin execution","messagePattern":"Failed to create shared tokio runtime for plugin execution","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/swc/src/plugin.rs","lineNumber":35,"sourceCode":"use swc_common::errors::{DiagnosticId, HANDLER};\nuse swc_ecma_ast::Pass;\n#[cfg(feature = \"plugin\")]\nuse swc_ecma_ast::*;\nuse swc_ecma_loader::{\n    resolve::Resolve,\n    resolvers::{lru::CachingResolver, node::NodeModulesResolver},\n};\nuse swc_ecma_visit::{fold_pass, noop_fold_type, Fold};\n#[cfg(feature = \"plugin\")]\nuse swc_plugin_runner::runtime::Runtime as PluginRuntime;\n\n/// Shared tokio runtime for plugin execution.\n/// This avoids the expensive overhead of creating a new runtime for each plugin\n/// call.\n#[cfg(all(feature = \"plugin\", not(feature = \"manual-tokio-runtime\")))]\nstatic SHARED_RUNTIME: Lazy<tokio::runtime::Runtime> = Lazy::new(|| {\n    tokio::runtime::Runtime::new()\n        .expect(\"Failed to create shared tokio runtime for plugin execution\")\n});\n\n/// A tuple represents a plugin.\n///\n/// First element is a resolvable name to the plugin, second is a JSON object\n/// that represents configuration option for those plugin.\n/// Type of plugin's configuration is up to each plugin - swc/core does not have\n/// strong type and it'll be serialized into plain string when it's passed to\n/// plugin's entrypoint function.\n#[derive(Debug, Clone, Serialize, Deserialize)]\n#[serde(deny_unknown_fields, rename_all = \"camelCase\")]\npub struct PluginConfig(pub String, pub serde_json::Value);\n\n#[cfg(feature = \"plugin\")]\npub(crate) fn plugins(\n    configured_plugins: Option<Vec<PluginConfig>>,\n    plugin_env_vars: Option<Vec<Atom>>,\n    metadata_context: std::sync::Arc<swc_common::plugin::metadata::TransformPluginMetadataContext>,","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc/src/plugin.rs#L17-L53","documentation":"In swc's plugin module, constructing the shared tokio Runtime used for plugin execution failed. This fires on first plugin invocation when the static initializer runs and tokio cannot build a runtime — typically in environments where spawning threads is restricted or resource limits prevent runtime creation. It is a one-time initialization failure affecting all subsequent plugin executions.","triggerScenarios":"Thrown at crates/swc/src/plugin.rs:35 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Enable the manual-tokio-runtime feature and provide an externally created runtime","Ensure the host environment allows thread spawning (required by tokio multi-thread runtime)","Check that no conflicting tokio runtime is already entered on the current thread","If plugins are not needed, disable the plugin feature"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}