Skip to content

[Bug] objForEachKey fails if there is a throwing getter for the property #627 - #637

Merged
nev21 merged 1 commit into
mainfrom
nev21/objForEachKey
Nov 8, 2026
Merged

nev21 merged 1 commit into
mainfrom
nev21/objForEachKey

Conversation

@nev21

@nev21 nev21 commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@nev21
nev21 requested review from a team as code owners November 8, 2026 00:45
Copilot AI balanced review requested due to automatic review settings November 8, 2026 00:45

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.

🟡 Changes recommended

Throwing getters cause object entries/values polyfills to diverge from native error propagation, while iterator callback types omit the possible undefined fallback, allowing unsafe consumers to type-check.

2 open issues
What changed in this PR

This PR addresses #627 by making the library’s object iterators continue when a property getter throws, passing undefined to the callback for that key.

Changes:

  • Share tolerant string-key iteration logic and apply equivalent handling to symbol keys.
  • Resolve callback this values once and add regression coverage for getter failures, early exit, and callback behavior.
  • Document the new behavior and its effect on polyObjKeys.
File Description
lib/​test/​src/​common/​polyfills/​object.test.ts Tests polyObjKeys with a throwing getter.
lib/​test/​src/​common/​object/​forEachOwnKeySafe.test.ts Tests getter failures and callback context for string and symbol iteration.
lib/​test/​src/​common/​object/​for_each_key.test.ts Tests getter failures, early exit, callback exceptions, and context.
lib/​src/​object/​forEachOwnKey.ts Reuses string-key iteration and handles throwing symbol getters.
lib/​src/​object/​for_each_key.ts Adds shared tolerant iteration and documents the fallback.
CHANGELOG.md Records the getter-handling fix and affected helpers.

Review effort: Balanced

Comment thread lib/src/object/for_each_key.ts Resolved
Comment thread lib/src/object/for_each_key.ts Resolved
@nev21
nev21 force-pushed the nev21/objForEachKey branch from 2dc187d to ff02a05 Compare November 8, 2026 03:36
Copilot AI balanced review requested due to automatic review settings November 8, 2026 03:36

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@codecov

codecov Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.21%. Comparing base (de437fe) to head (6e49da4).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #637      +/-   ##
==========================================
+ Coverage   99.19%   99.21%   +0.02%     
==========================================
  Files         180      180              
  Lines        5573     5590      +17     
  Branches     1248     1295      +47     
==========================================
+ Hits         5528     5546      +18     
+ Misses         45       44       -1     
Files with missing lines Coverage Δ
lib/src/object/forEachOwnKey.ts 100.00% <100.00%> (+3.70%) ⬆️
lib/src/object/for_each_key.ts 100.00% <100.00%> (ø)
lib/src/polyfills/object/objKeys.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nev21
nev21 force-pushed the nev21/objForEachKey branch from ff02a05 to 6e49da4 Compare November 8, 2026 04:17
Copilot AI balanced review requested due to automatic review settings November 8, 2026 04:17

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@nevware21-bot nevware21-bot 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.

Approved by nevware21-bot

@nev21
nev21 merged commit 49bffdb into main Nov 8, 2026
10 checks passed
@nev21
nev21 deleted the nev21/objForEachKey branch November 8, 2026 04:32
@nev21 nev21 added this to the 0.17.0 milestone Nov 8, 2026
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.

3 participants