Skip to content

fix: guard selectDropDownContainer.remove() against already-removed node (fixes #315703)#315709

Open
vs-code-engineering[bot] wants to merge 1 commit into
mainfrom
fix/select-box-remove-error-315703-997cef39e2d1832e
Open

fix: guard selectDropDownContainer.remove() against already-removed node (fixes #315703)#315709
vs-code-engineering[bot] wants to merge 1 commit into
mainfrom
fix/select-box-remove-error-315703-997cef39e2d1832e

Conversation

@vs-code-engineering
Copy link
Copy Markdown
Contributor

@vs-code-engineering vs-code-engineering Bot commented May 11, 2026

🔧 Error Fix

Summary

Error: NotFoundError: Failed to execute 'remove' on 'Element': The node to be removed is no longer a child of this node.

Bucket: 5dab52a4-d055-fd3c-d16c-a042f3d75688

The settings editor triggers cancelSuggesters() on scroll via updateTreeScrollSync(). This hides the context view, which disposes the select box dropdown. The dispose callback calls selectDropDownContainer.remove(). However, a browser blur event (triggered by the same scroll action) can remove the DOM node before the dispose callback runs, causing the NotFoundError.

Fixes #315703
Recommended reviewer: @mrleemurray

Culprit Commit

No specific culprit commit identified. This is a long-standing race condition between browser blur events and the dispose lifecycle of the select box dropdown.

Code Flow

sequenceDiagram
    participant SE as settingsEditor2
    participant ST as settingsTree
    participant CV as contextViewService
    participant SB as selectBoxCustom
    participant DOM as Browser DOM
    SE->>ST: cancelSuggesters()
    ST->>CV: hideContextView()
    CV->>SB: dispose()
    Note over DOM: blur event already removed the node
    SB->>DOM: selectDropDownContainer.remove()
    DOM-->>SB: NotFoundError!
Loading

Affected Files

File Role
src/vs/base/browser/ui/selectBox/selectBoxCustom.ts Crash site
src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts Triggers scroll sync
src/vs/workbench/contrib/preferences/browser/settingsTree.ts Calls hideContextView()

How the Fix Works

Chosen approach (src/vs/base/browser/ui/selectBox/selectBoxCustom.ts:531): Added a parentNode guard before calling .remove(). The producer of the invalid state is the browser blur event handler which removes the DOM node before our dispose runs. We cannot prevent the browser behavior, so a guard clause is the correct fix - it prevents the error without hiding any bug.

Recommended Owner

@mrleemurray - recent owner of selectBoxCustom.ts

errors-fix-driver — cycle 25

Trigger: cron_review_comments · Head: 4a85d016b2b0978c04890e5b677dd86f2d74135f (4a85d01)

Item Action
CI (25/25 checks) All passing ✅
Review threads None unresolved
Merge state blocked (awaiting approval)

Push: no — no code changes needed · Copilot rerequested: no (no push)

Ready gate: CI green. No unresolved threads. PR is not draft. Awaiting human approval from @mrleemurray.

errors-fix-driver — cycle 26

Trigger: cron_review_comments · Head: 4a85d016b2b0978c04890e5b677dd86f2d74135f (4a85d01)

Item Action
CI (25/25 checks) All passing ✅
Review threads None unresolved
Merge state blocked (awaiting approval)

Push: no — no code changes needed · Copilot rerequested: no (no push)

Ready gate: CI green. No unresolved threads. PR is not draft. Awaiting human approval from @mrleemurray.

errors-fix-driver — cycle 27

Trigger: cron_review_comments · Head: 4a85d016b2b0978c04890e5b677dd86f2d74135f (4a85d01)

Item Action
CI (25/25 checks) All passing ✅
Review threads None unresolved
Merge state blocked (awaiting approval)

Push: no — no code changes needed · Copilot rerequested: no (no push)

Ready gate: CI green. No unresolved threads. PR is not draft. Awaiting human approval from @mrleemurray.

Generated by errors-fix-driver · ● 4.6M ·

…ode (fixes #315703)

The dispose callback in selectBoxCustom calls .remove() on the dropdown
container, but a browser blur event (triggered by scroll in the settings
editor) can remove the node first. Add a parentNode guard to prevent the
NotFoundError.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 11, 2026 15:51
@vs-code-engineering vs-code-engineering Bot requested review from Copilot and mrleemurray and removed request for Copilot May 11, 2026 15:51
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@vs-code-engineering vs-code-engineering Bot marked this pull request as ready for review May 11, 2026 15:52
@vs-code-engineering vs-code-engineering Bot enabled auto-merge (squash) May 13, 2026 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Error] unhandlederror-Uncaught NotFoundError: Failed to execute 'remove' on 'Element': The node to be remov...

2 participants