{"record":{"id":"bbf7f2b1a58d3325","repo":"denoland/deno","slug":"unable-to-get-organize-imports-edit-from-typescrip","errorCode":null,"errorMessage":"Unable to get organize imports edit from TypeScript: {:#}","messagePattern":"Unable to get organize imports edit from TypeScript: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/lsp/ts_server.rs","lineNumber":469,"sourceCode":"          .collect::<Result<Vec<_>, _>>()?\n          .into_iter()\n          .flatten();\n        actions.extend(\n          refactor::prune_invalid_actions(refactor_actions, 5)\n            .into_iter()\n            .map(lsp::CodeActionOrCommand::CodeAction),\n        );\n\n        if !snapshot.config.client_provided_organize_imports_capable()\n          && context.only.as_ref().is_none_or(|o| {\n            o.contains(&lsp::CodeActionKind::SOURCE_ORGANIZE_IMPORTS)\n          })\n        {\n          let organize_imports_edit = ts_server\n            .organize_imports(snapshot.clone(), module, token)\n            .await\n            .map_err(|err| {\n              anyhow!(\n                \"Unable to get organize imports edit from TypeScript: {:#}\",\n                err\n              )\n            })?;\n          let text_edits = organize_imports_edit.first().map(|c| {\n            c.text_changes\n              .iter()\n              .map(|c| c.as_text_edit(&module.line_index))\n              .collect::<Vec<_>>()\n          });\n          if let Some(text_edits) = text_edits\n            && !text_edits.is_empty()\n          {\n            actions.push(lsp::CodeActionOrCommand::CodeAction(\n              lsp::CodeAction {\n                title: \"Organize Imports\".to_string(),\n                kind: Some(lsp::CodeActionKind::SOURCE_ORGANIZE_IMPORTS),\n                edit: Some(lsp::WorkspaceEdit {","sourceCodeStart":451,"sourceCodeEnd":487,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/lsp/ts_server.rs#L451-L487","documentation":"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).","triggerScenarios":"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.","commonSituations":"Organize-imports-on-save racing rapid edits; the feature intermittently failing while the language server is busy or restarting.","solutions":["Save the file and retry organize imports once edits settle.","Run \"Deno: Restart Language Server\" if it keeps failing.","Update the Deno CLI and IDE extension.","Check the wrapped error after the colon in the Deno Language Server output to identify the tsc failure."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"// If server-side organize imports fails, skip the edit instead of\n// failing the save action.\ntry {\n  await applyOrganizeImports(client, textDocument);\n} catch (err) {\n  if (String(err?.message).includes('organize imports edit')) {\n    console.warn('organize imports skipped:', err.message); // file saved unchanged\n  } else {\n    throw err;\n  }\n}","preventionTips":["Save and retry organize imports rather than running it mid-keystroke","Run 'deno fmt' or organize imports from the CLI ('deno check' + manual ordering) when the server path keeps failing","Restart the language server and keep Deno updated"],"tags":["lsp","organize-imports","tsc","code-actions"],"backgroundTag":"lsp-tsc-request-failed","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}