Skip to content

fix: race condition in notebook kernel picker - #341483

Merged
Dmitriy Vasyura (dmitrivMS) merged 1 commit into
microsoft:mainfrom
SimonSiefke:fix/notebookKernelQuickPick-ordering
Nov 11, 2026
Merged

Dmitriy Vasyura (dmitrivMS) merged 1 commit into
microsoft:mainfrom
SimonSiefke:fix/notebookKernelQuickPick-ordering

Conversation

@SimonSiefke

@SimonSiefke Simon Siefke (SimonSiefke) commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

This PR is needed for #336032


Details

Opening the notebook kernel picker asks extensions which kernel sources are available. The picker can refresh while an earlier request is still running.

If that earlier request finishes last, it can overwrite newer choices or stop the loading indicator too soon. A request can also finish after the picker closes and try to update it.

Change

Only the most recent request can update the choices and loading indicator. Once you select an item, go back, or close the picker, pending results are ignored.

Before

A slow, older response can replace the current choices with outdated ones, or make the picker look finished while the latest request is still loading.

After

The picker keeps the latest choices, shows loading while the current request is pending, and ignores results that arrive after it closes.

All five regression tests fail on the original code and pass with this fix. Also verified in Code OSS, including selecting a source and closing or reopening the picker while requests are pending.


AI disclosure: Model: GPT 6.1 Sol. Worktime: approximately 18 min

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The lifecycle and ordering guards correctly address the race, with focused regression coverage and no unresolved issues.

0 open findings

What changed in this PR

Prevents stale asynchronous kernel-source requests from updating a closed or refreshed notebook kernel picker.

Changes:

  • Tracks request generations and ignores obsolete results.
  • Stops updates after picker completion or closure.
  • Adds five regression tests covering request ordering and lifecycle races.
File Description
notebookKernelQuickPickStrategy.ts Guards picker updates by request generation and closed state.
notebookKernelQuickPickStrategy.test.ts Tests stale responses, loading state, empty results, and closure.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the notebook kernel-source picker race-condition fix.

No open issues 🎉

Review effort: Max

auto-merge was automatically disabled November 11, 2026 09:54

Pull request was closed

@dmitrivMS
Dmitriy Vasyura (dmitrivMS) merged commit d2385e5 into microsoft:main Nov 11, 2026
103 of 105 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.147.0 milestone Nov 11, 2026
@SimonSiefke
Simon Siefke (SimonSiefke) deleted the fix/notebookKernelQuickPick-ordering branch November 11, 2026 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

6 participants