Repository navigation
fix: memory leak in notebookCellLinkifier - #340149
Open
Simon Siefke (SimonSiefke) wants to merge 14 commits into
Open
Simon Siefke (SimonSiefke) wants to merge 14 commits into
Simon Siefke (SimonSiefke) wants to merge 14 commits into
Conversation
…ry-leak-notebook-cell-linkifier
Copilot started reviewing on behalf of
Simon Siefke (SimonSiefke)
October 6, 2026 21:35
View session
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The last-notebook close path bypasses the newly added WeakMap cleanup.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Fixes repeated notebook listener registration and stale cell-ID tracking.
Changes:
- Initializes listeners once per linkifier.
- Clears stale IDs and removes closed notebook entries.
- Adds listener lifecycle coverage.
| File | Description |
|---|---|
notebookCellLinkifier.ts |
Updates listener and cell-ID lifecycle cleanup. |
notebookCellLinkifier.spec.ts |
Tests listener registration and disposal. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Details
Repeated notebook cell lookups register the same workspace listeners again because the initialized flag is never set.
Change
Set the initialized flag, clear old cell IDs when rebuilding the index, and remove notebook entries when they close.
Before
Across 37 chat responses with three notebook cell links each, clearing chat after every response,
named-function-count3detects +111 per notebook callback. The red box marks rows with reduced growth after the fix.After
Callback growth drops to +37 per callback. A separate leak remains: each response creates a linkifier that stays until feature deactivation (+37 instances).
Test Video
notebook-cell-links.mp4
AI disclosure: Model: Some kind of OpenAI model. Worktime: n/a