Skip to content

Fix LinkedMap.delete result for falsy values - #1943

Open
Raunak Kumar Pandey (raunakpandey1) wants to merge 1 commit into
microsoft:mainfrom
raunakpandey1:fix/linked-map-delete-falsy-values
Open

Raunak Kumar Pandey (raunakpandey1) wants to merge 1 commit into
microsoft:mainfrom
raunakpandey1:fix/linked-map-delete-falsy-values

Conversation

@raunakpandey1

@raunakpandey1 Raunak Kumar Pandey (raunakpandey1) commented Nov 2, 2026 •

Copy link
Copy Markdown

LinkedMap.delete removes entries with falsy stored values but returns false, because it converts the value returned by remove to a boolean. This also affects the exported LRUCache, which inherits the method.

Check key presence before calling the existing removal path so deletion reports whether the key existed. The regression tests exercise both classes with 0, -0, false, '', null, undefined, NaN, and a truthy control. They also check absent/repeated deletions, size, and iteration order.

Fixes #1942.

Validation on macOS arm64, Node.js 22.22.3:

  • The two new tests fail against the original implementation (false !== true for value 0).
  • npm run compile:jsonrpc passed.
  • npm --prefix jsonrpc run test:node: 79 passing. The transport tests required local socket permissions.
  • npm --prefix jsonrpc run lint passed, with an existing stylistic configuration deprecation warning.
  • git diff --check passed.
  • The browser bundle built, but browser execution could not start because Playwright Chromium was absent. A Chromium download did not complete and was stopped. Browser tests and repository-wide/VS Code integration tests are not claimed as passing.

Copilot AI balanced review requested due to automatic review settings November 2, 2026 22:11

Copilot AI left a comment

Copy link
Copy Markdown

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 remain for the change making LinkedMap and LRUCache deletion results reflect key presence.

No open issues 🎉

What changed in this PR

Fixes #1942 by making LinkedMap.delete return whether the key existed, regardless of its stored value. The correction also applies to LRUCache, which inherits the method.

Changes:

  • Check key presence before using the existing removal path.
  • Add regression tests for both classes covering falsy and truthy values, missing and repeated deletions, size, and iteration order.
File Description
jsonrpc/​src/​common/​test/​linkedMap.test.ts Adds deletion regression coverage for LinkedMap and LRUCache.
jsonrpc/​src/​common/​linkedMap.ts Returns key presence instead of the removed value’s truthiness.

Review effort: Balanced

@raunakpandey1

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Raunak Kumar Pandey (Raunak Kumar Pandey (@raunakpandey1)) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LinkedMap.delete and LRUCache.delete return false for existing falsy values

2 participants