{"record":{"id":"31364f512ac9631e","repo":"sinelaw/fresh","slug":"failed-to-create-quickjs-context","errorCode":null,"errorMessage":"Failed to create QuickJS context: {}","messagePattern":"Failed to create QuickJS context: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/fresh-plugin-runtime/src/backend/quickjs_backend.rs","lineNumber":8942,"sourceCode":"                            request_id,\n                            ok: false,\n                            output: None,\n                            error: Some(error_msg.clone()),\n                        });\n                    }\n\n                    if should_panic_on_js_errors() {\n                        // Don't panic here - we're inside an FFI callback and rquickjs catches panics.\n                        // Instead, set a fatal error flag that the plugin thread loop will check.\n                        let full_msg = format!(\"Unhandled Promise rejection: {}\", error_msg);\n                        set_fatal_js_error(full_msg);\n                    }\n                }\n            },\n        )));\n\n        let main_context = Context::full(&runtime)\n            .map_err(|e| anyhow!(\"Failed to create QuickJS context: {}\", e))?;\n\n        let plugin_contexts = Rc::new(RefCell::new(HashMap::new()));\n        let registered_actions = Rc::new(RefCell::new(HashMap::new()));\n        let next_request_id = Rc::new(RefCell::new(1u64));\n        let callback_contexts = Rc::new(RefCell::new(HashMap::new()));\n        let plugin_tracked_state = Rc::new(RefCell::new(HashMap::new()));\n        let registered_command_names = Rc::new(RefCell::new(HashMap::new()));\n        let registered_grammar_languages = Rc::new(RefCell::new(HashMap::new()));\n        let registered_language_configs = Rc::new(RefCell::new(HashMap::new()));\n        let registered_lsp_servers = Rc::new(RefCell::new(HashMap::new()));\n        let plugin_api_exports = Rc::new(RefCell::new(HashMap::new()));\n\n        let backend = Self {\n            runtime,\n            main_context,\n            plugin_contexts,\n            event_handlers,\n            registered_actions,","sourceCodeStart":8924,"sourceCodeEnd":8960,"githubUrl":"https://github.com/sinelaw/fresh/blob/67894ca5463dbd7a89bb31add4627c27d6b79d83/crates/fresh-plugin-runtime/src/backend/quickjs_backend.rs#L8924-L8960","documentation":"Initialization failure of the QuickJS execution Context on top of an already-created runtime: rquickjs's Context::new() (or the immediate global setup that follows) failed. This means the engine runtime exists but no JS context can be fabricated, so the plugin backend cannot evaluate any code; the wrapped error is returned from the backend constructor path and prevents plugin loading entirely.","triggerScenarios":"Context::full() fails — engine-level failure while allocating a context on an otherwise-created runtime; usually indicates corrupted runtime state, exhausted memory, or an rquickjs internal error.","commonSituations":"Memory-pressure environments where the runtime was created but a context cannot be allocated; rquickjs version incompatibilities; constructing many backends rapidly in the same process.","solutions":["Check memory limits and available RAM","Recreate the backend (drop and rebuild QuickJsBackend)","Check the wrapped rquickjs error for the concrete cause","Update or rebuild rquickjs to match the platform"],"exampleFix":"// before\nlet backend = QuickJsBackend::new(...)?; // after runtime OOM\n// after\n// free memory / lower concurrency, then:\nlet backend = QuickJsBackend::new(...).context(\"plugin backend init\")?;","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match QuickJsBackend::new(...) {\n    Err(e) if e.to_string().contains(\"Failed to create QuickJS context\") => {\n        tracing::error!(\"context init failed: {e:#}\");\n        retry_after_gc_or_restart_backend()\n    }\n    other => other,\n}","preventionTips":["Monitor process memory; contexts need headroom after runtime creation","Avoid rapid create/drop cycles of many backends","Keep rquickjs versions aligned across the workspace","Fail fast at startup with a clear message instead of lazy init"],"tags":["quickjs","context-init","memory"],"backgroundTag":"module-init-failed","analyzedSha":"67894ca5463dbd7a89bb31add4627c27d6b79d83","analyzedAt":"2026-09-13T15:04:03.701Z","contentChangedAt":"2026-09-13T15:04:03.701Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}