denoland/deno · error

Unable to convert refactor info: {:#}

Error message

Unable to convert refactor info: {:#}

What it means

After tsc returns applicable refactor infos, each is converted into LSP code actions via refactor_info.to_code_actions; this wraps a conversion failure for one entry. Causes include refactor spans that fail to map through the module's line index (stale snapshot) and refactor metadata whose shape the server does not expect from the embedded TypeScript version.

Source

Thrown at cli/lsp/ts_server.rs:448

            snapshot.clone(),
            module,
            module.line_index.offset_tsc(range.start)?
              ..module.line_index.offset_tsc(range.end)?,
            context.trigger_kind,
            only,
            token,
          )
          .await
          .map_err(|err| {
            anyhow!("Unable to get refactor info from TypeScript: {:#}", err)
          })?;
        let refactor_actions = refactor_infos
          .into_iter()
          .map(|refactor_info| {
            refactor_info
              .to_code_actions(&module.uri, &range, token)
              .map_err(|err| {
                anyhow!("Unable to convert refactor info: {:#}", err)
              })
          })
          .collect::<Result<Vec<_>, _>>()?
          .into_iter()
          .flatten();
        actions.extend(
          refactor::prune_invalid_actions(refactor_actions, 5)
            .into_iter()
            .map(lsp::CodeActionOrCommand::CodeAction),
        );

        if !snapshot.config.client_provided_organize_imports_capable()
          && context.only.as_ref().is_none_or(|o| {
            o.contains(&lsp::CodeActionKind::SOURCE_ORGANIZE_IMPORTS)
          })
        {
          let organize_imports_edit = ts_server
            .organize_imports(snapshot.clone(), module, token)

View on GitHub (pinned to 9ad36f7a2c)

Solutions

  1. Save the file and retry the refactoring after edits settle.
  2. Ensure the Deno CLI and IDE extension are both current and matched — refactor info shapes change between tsc versions.
  3. Run "Deno: Restart Language Server" if the failure persists.
  4. Inspect the wrapped error after the colon in the language server output.
Defensive patterns

Strategy: fallback

Try / catch

// One bad refactor entry aborts the whole conversion on the server;
// fall back to offering no server refactors for that invocation.
try {
  actions = await collectRefactorActions(client, params);
} catch (err) {
  if (String(err?.message).includes('Unable to convert refactor info')) {
    actions = []; // user can still rename/extract manually; log for triage
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: A code action request over a range where one refactor info entry fails conversion — spans that do not map onto the current document snapshot, or a tsc/server version mismatch in the expected refactor JSON shape.

Common situations: Requesting refactorings right after rapid edits; mixing an outdated VS Code extension with a newer Deno CLI (or vice versa).

Related errors


AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20). Data as JSON: /api/errors/c20f09f924d4742b. Report an issue: GitHub.