{"record":{"id":"4247298af5a1aa64","repo":"denoland/deno","slug":"failed-to-evaluate-expression","errorCode":null,"errorMessage":"failed to evaluate expression","messagePattern":"failed to evaluate expression","errorType":"exception","errorClass":"AnyError","httpStatus":null,"severity":"error","filePath":"cli/tools/repl/session.rs","lineNumber":779,"sourceCode":"    let response = self\n      .call_function_on_repl_internal_obj(\n        r#\"function (object) {\n          try {\n            return this.inspectArgs([\"%o\", object], { colors: !this.noColor });\n          } catch (err) {\n            return this.inspectArgs([\"%o\", err]);\n          }\n        }\"#\n          .to_string(),\n        std::slice::from_ref(evaluate_result),\n      )\n      .await?;\n    let s = response\n      .result\n      .value\n      .map(|v| v.as_str().unwrap().to_string())\n      .or(response.result.description)\n      .ok_or_else(|| anyhow!(\"failed to evaluate expression\"))?;\n\n    Ok(s)\n  }\n\n  async fn evaluate_ts_expression(\n    &mut self,\n    expression: &str,\n  ) -> Result<TsEvaluateResponse, AnyError> {\n    let tsx_result =\n      parse_source_as(expression.to_string(), deno_ast::MediaType::Tsx);\n    // Prefer a clean `.tsx` parse. Fall back to parsing as TypeScript when the\n    // `.tsx` parse fails outright, or when it only recovered by inserting an\n    // `Invalid` placeholder node (e.g. a TypeScript type assertion like\n    // `<string>x` is misread as JSX in `.tsx`).\n    let needs_ts_fallback = match &tsx_result {\n      Ok(parsed) => {\n        deno_resolver::emit::invalid_syntax_parse_diagnostics(parsed).is_some()\n      }","sourceCodeStart":761,"sourceCodeEnd":797,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/tools/repl/session.rs#L761-L797","documentation":"Thrown by the REPL's result formatter (get_eval_value in cli/tools/repl/session.rs). After an expression evaluates, the REPL calls its internal inspectArgs helper over the Chrome DevTools protocol (Runtime.callFunctionOn) to stringify the result; the error fires when the response carries neither a string `value` nor a `description` on the returned RemoteObject, so nothing is printable. It is an internal inspection round-trip failure, not a type error in the evaluated expression itself.","triggerScenarios":"Evaluating an expression in the `deno` REPL whose inspect round-trip returns an empty RemoteObject: pressing Ctrl-C between evaluation and formatting, awaiting something that detaches or invalidates the execution context, or an object (Proxy, throwing getter) whose inspection fails in a way that also breaks the catch branch of the injected function at session.rs:763-769.","commonSituations":"Interrupting the REPL while it formats a huge or deeply nested object; getter-heavy config objects; long-lived REPL sessions left open across a deno upgrade; REPL driven through wrappers that mangle stdout.","solutions":["Re-run the same expression; transient inspection glitches usually clear on the next evaluation.","Bypass the inspector formatter with an explicit conversion: JSON.stringify(x), String(x), or x?.toString().","Restart the REPL (deno) so the internal inspectArgs helper is re-created.","If one specific expression reproduces it every time, minimize it and report at https://github.com/denoland/deno/issues."],"exampleFix":"// before (REPL): inspector formatting of an exotic object fails\n> config\nerror: failed to evaluate expression\n\n// after: force a primitive yourself\n> JSON.stringify(config, null, 2)","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Avoid Ctrl-C while the REPL is formatting a result — interrupt before evaluation completes instead.","Prefer explicit JSON.stringify(value) / String(value) for Proxy objects or objects with throwing getters.","Restart the REPL if failures repeat within one session; it rebuilds the internal inspectArgs helper."],"tags":["repl","inspector","evaluate","cli"],"backgroundTag":"expression-evaluation-failed","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}