denoland/deno · error

Unable to get organize imports edit from TypeScript: {:#}

Error message

Unable to get organize imports edit from TypeScript: {:#}

What it means

When the client cannot organize imports itself, the Deno LSP supplies the source.organizeImports action by calling tsc's organizeImports (see snapshot.config.client_provided_organize_imports_capable in the source); this wraps that request's failure. The tsc error follows the colon. Bad import syntax normally produces edits or diagnostics, not this error — it indicates the tsc request itself failed (cancellation, isolate crash).

Source

Thrown at cli/lsp/ts_server.rs:469

          .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)
            .await
            .map_err(|err| {
              anyhow!(
                "Unable to get organize imports edit from TypeScript: {:#}",
                err
              )
            })?;
          let text_edits = organize_imports_edit.first().map(|c| {
            c.text_changes
              .iter()
              .map(|c| c.as_text_edit(&module.line_index))
              .collect::<Vec<_>>()
          });
          if let Some(text_edits) = text_edits
            && !text_edits.is_empty()
          {
            actions.push(lsp::CodeActionOrCommand::CodeAction(
              lsp::CodeAction {
                title: "Organize Imports".to_string(),
                kind: Some(lsp::CodeActionKind::SOURCE_ORGANIZE_IMPORTS),
                edit: Some(lsp::WorkspaceEdit {

View on GitHub (pinned to 9ad36f7a2c)

Solutions

  1. Save the file and retry organize imports once edits settle.
  2. Run "Deno: Restart Language Server" if it keeps failing.
  3. Update the Deno CLI and IDE extension.
  4. Check the wrapped error after the colon in the Deno Language Server output to identify the tsc failure.
Defensive patterns

Strategy: fallback

Try / catch

// If server-side organize imports fails, skip the edit instead of
// failing the save action.
try {
  await applyOrganizeImports(client, textDocument);
} catch (err) {
  if (String(err?.message).includes('organize imports edit')) {
    console.warn('organize imports skipped:', err.message); // file saved unchanged
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: Running Organize Imports (manually or via codeActionsOnSave with source.organizeImports) while the client lacks the organize-imports capability, and the tsc organizeImports request fails or is cancelled.

Common situations: Organize-imports-on-save racing rapid edits; the feature intermittently failing while the language server is busy or restarting.

Related errors


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