{"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":"anyhow::Error","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/89f33cbef296a2b287f323d42de54c871fa69c77/cli/tools/repl/session.rs#L761-L797","documentation":"In the REPL, each evaluated expression is stringified through the DevTools inspector: deno takes the RemoteObject's `value` or falls back to `description`. If the inspector response carries neither field, deno cannot render a result and throws `failed to evaluate expression`. This is a degenerate protocol response (empty payload or race), not a syntax error in the user's expression.","triggerScenarios":"Evaluating an expression whose inspector RemoteObject arrives with neither value nor description — certain exotic objects or a transient inspector hiccup mid-session.","commonSituations":"Long-running REPL sessions; evaluating constructs that return unusual remote-object shapes; intermittent occurrences after heavy session activity.","solutions":["Re-run the expression — it is usually transient","Render the result a different way: console.log(expr) or Deno.inspect(value)","Restart the REPL session if it keeps recurring","If reproducible on the latest Deno, minimize the expression and open an issue"],"exampleFix":"// before — bare evaluation of a result the inspector cannot stringify\n>>> myObject\n// after — inspect explicitly\n>>> console.log(myObject)\n>>> Deno.inspect(myObject, { depth: 4 })","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer explicit output (console.log / Deno.inspect) for values you need to see reliably","Restart the REPL when inspector responses degrade in long sessions","Report reproducible cases with the exact expression to the Deno repo"],"tags":["repl","inspector","devtools-protocol","runtime"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}