Dependencies view: `getParent` loops forever on untitled documents, extension host runs out of memory
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 70/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- typescript, vscode
- 領域
- tooling
調査の方向性
ループは vscode/src/dependenciesTree.ts にあります。getParent(55行目付近)はパスのルートに到達するまで親をたどり、activeEditorDidChange(92行目付近)はスキームに関係なく、アクティブなエディターの URI を reveal するため、untitled ドキュメントは延々とたどられ続けます。まずこの2つの関数と、記憶された currentVisibleItem も reveal する treeVisibilityDidChange を読んでください。untitled エディターをアクティブにしても reveal も親のたどりも発生せず、絶対パスでない、または前進しない親パスに対して getParent が undefined を返すようになれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Description
Ruby LSP Information
VS Code Version
1.141.0
Ruby LSP Extension Version
0.10.6
Ruby LSP Server Version
0.26.11
Ruby LSP Add-ons
- Ruby LSP Rails (0.4.8)
- RuboCop (1.86.1)
Ruby Version
3.4.7
Ruby Version Manager
mise
Installed Extensions
Click to expand
- bruno (6.0.0)
- claude-code (2.1.296)
- gitlab-workflow (7.2.0)
- ruby-extensions-pack (0.1.14)
- ruby-lsp (0.10.6)
- sorbet-vscode-extension (0.3.47)
- sql-developer (26.3.0)
- vscode-yaml (1.25.0)
Ruby LSP Settings
Click to expand
Workspace
{}
User
{
"enabledFeatures": {
"codeActions": true,
"diagnostics": true,
"documentHighlights": true,
"documentLink": true,
"documentSymbols": true,
"foldingRanges": true,
"formatting": true,
"hover": true,
"inlayHint": true,
"onTypeFormatting": true,
"selectionRanges": true,
"semanticHighlighting": true,
"completion": false,
"codeLens": true,
"definition": true,
"workspaceSymbol": true,
"signatureHelp": true,
"typeHierarchy": true
},
"featuresConfiguration": {},
"addonSettings": {},
"rubyVersionManager": {
"identifier": "auto"
},
"customRubyCommand": "",
"formatter": "rubocop_internal",
"linters": [
"rubocop_internal"
],
"bundleGemfile": "",
"testTimeout": 30,
"pullDiagnosticsOn": "both",
"useBundlerCompose": false,
"bypassTypechecker": false,
"rubyExecutablePath": "sh",
"indexing": {},
"erbSupport": true,
"featureFlags": {},
"sigOpacityLevel": "1"
}
Also: Remote – Dev Containers on linux-arm64 (Apple Silicon host), explorer.autoReveal left at its default (true). All versions above are the latest stable releases, and the same code is still on main.
Reproduction steps
- Start the Ruby LSP in VS Code by opening a Rails project.
- In the Explorer, expand the Dependencies view so its contents are visible.
- Create an untitled document with File → New Text File (
Untitled-N). - Click a saved file, then click back to the untitled tab.
- The extension host's memory starts climbing straight away (591 MB → 1.46 GB in about 20 seconds) until V8 aborts it with
JavaScript heap out of memory. The VS Code window hangs in the meantime.
No other extensions are needed. We first hit this through Oracle SQL Developer worksheets, which are also untitled documents.
It also triggers if an untitled editor is active while the Dependencies view is hidden and you then show the view, because currentVisibleItem is remembered and revealed in treeVisibilityDidChange.
Expected: nothing happens, because an untitled document can't be part of any gem.
Code snippet or error message
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
Extension Host Process exited with code: null, signal: SIGABRT.
Heap-allocation profile of the extension host while memory was growing:
-- live allocations by extension
65.3% (vscode core)
34.3% shopify.ruby-lsp
-- top allocating functions
49.0% (vscode core) :: r extensionHostProcess.js:28
34.1% shopify.ruby-lsp :: getParent extension.js:79
15.5% (vscode core) :: (anon) extensionHostProcess.js:294
0.3% (vscode core) :: _resolveParent extensionHostProcess.js:294
0.3% (vscode core) :: joinPath extensionHostProcess.js:28
The cause seems to be in vscode/src/dependenciesTree.ts. activeEditorDidChange (line 92) wraps any active editor's URI in a GemFilePath and reveals it, whatever its scheme. TreeView.reveal then calls getParent (line 55) until it returns undefined, and getParent only stops when parentUri.path === path.parse(parentUri.path).root:
getParent(element: BundlerTreeNode): vscode.ProviderResult<BundlerTreeNode> {
const parentUri = vscode.Uri.joinPath(element.resourceUri, "..");
const rootPath = path.parse(parentUri.path).root;
if (parentUri.path === rootPath) {
return undefined;
}
// ...otherwise returns a gem root or a new GemDirectoryPath(parentUri)
}
For a file: URI the walk ends at /. An untitled document's path has no leading /, so rootPath is "", and joining .. never produces "":
/workspaces/app/db/x.sql -> /workspaces/app/db -> /workspaces/app -> /workspaces -> / (stops)
Untitled-2 -> . -> .. -> ../.. -> ../../.. -> ../../../.. -> ... (never stops)
(The trace comes from running the same check with path.posix.join in Node. The profile above matches it.)
Possible fix: skip non-file: URIs in activeEditorDidChange, ideally only revealing URIs under one of gemRootFolders. As a safety net, getParent could return undefined when the parent path isn't absolute or equals the current path:
const uri = editor?.document.uri;
if (!uri || uri.scheme !== "file") {
return;
}
Workaround: hide the Dependencies view, or set "explorer.autoReveal": false.
- 主要言語
- Ruby
- スター
- 2k
- フォーク
- 283
- 平均マージ
- 9時間 18分
- マージ済み PR(30日)
- 11
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Shopify/ruby-lsp のほかの issue
-
Linux file system with square brackets in the directory/filename are failing to be indexed対応中かも @andriytyurnikov が 215 日前に担当しました。 オープンbug help-wanted pinned
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Shopify/ruby-lsp#3503 · コメント 8 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
rbenv activation leaks RBENV_VERSION and RBENV_DIR into process.env of the extension host対応中かも @efegokdemir が 6 日前に担当しました。 オープンbug
難易度 3/5 半日 初心者へのやさしさ 45/100
メンテナーはふだん 1 日以内に返信
-
Rename of a class moves its file and leaves require_relative on the old path対応中かも @efegokdemir が 12 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 22/100
メンテナーはふだん 1 日以内に返信
-
Paths need to be escaped対応中かも @Vraiment が 16 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 25/100
メンテナーはふだん 1 日以内に返信
-
check-labels intermittently fails due to the organization IP allow list対応中かも @soutaro が 19 日前に担当しました。 オープン
Shopify/ruby-lsp#4219 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
Shopify/ruby-lsp の issue をすべて見る
似ている issue
-
`github-events` aborts the repository scan when a closed pull's API payload has a null `head`対応中かも @renyamamoto2026-cmyk が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
zerocracy/judges-action#2823 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
aws/aws-sdk-ruby#3460 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
メンテナーはふだん 17 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
riscv/riscv-unified-db#2755 ·
メンテナーはふだん 1 日以内に返信