Skip to content

fix: cap unwrap depth in timeout normalization#528

Merged
nev21 merged 4 commits into
mainfrom
nev21/NormalizeTimeout
Jul 9, 2026
Merged

fix: cap unwrap depth in timeout normalization#528
nev21 merged 4 commits into
mainfrom
nev21/NormalizeTimeout

Conversation

@nev21

@nev21 nev21 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Bound the array-unwrapping loop in _normalizeTimeoutValue to 5 iterations, falling back to the default timeout if no numeric value is found within that bound. Previously a self-referential array (e.g. a[0] = a) passed as a timeout would loop forever.

@nev21 nev21 added this to the 0.7.0 milestone Jul 8, 2026
@nev21 nev21 requested a review from a team as a code owner July 8, 2026 04:20
Copilot AI review requested due to automatic review settings July 8, 2026 04:20
@nev21 nev21 requested a review from a team as a code owner July 8, 2026 04:20

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.

Pull request overview

This PR prevents _normalizeTimeoutValue from looping forever when given a self-referential array timeout by capping nested-array unwrapping to a fixed depth and adding unit tests around normalization behavior.

Changes:

  • Added a maximum unwrap depth constant and bounded the array-unwrapping loop in _normalizeTimeoutValue.
  • Added a new test suite covering direct numeric timeouts, nested arrays, depth-cap behavior, and self-referential arrays.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
lib/src/internal/timeout_helpers.ts Caps nested array unwrapping in _normalizeTimeoutValue to avoid infinite loops on cyclic/self-referential arrays.
lib/test/src/internal/timeout_helpers.test.ts Adds coverage for timeout normalization, including depth-cap and self-referential array scenarios.

Comment thread lib/src/internal/timeout_helpers.ts
@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.57%. Comparing base (c133f5a) to head (b4fd64b).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #528      +/-   ##
==========================================
+ Coverage   97.55%   97.57%   +0.01%     
==========================================
  Files          28       28              
  Lines        1516     1527      +11     
  Branches      358      358              
==========================================
+ Hits         1479     1490      +11     
  Misses         37       37              
Files with missing lines Coverage Δ
lib/src/internal/timeout_helpers.ts 100.00% <100.00%> (ø)
lib/src/promise/asyncPromise.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.

nevware21-bot
nevware21-bot previously approved these changes Jul 8, 2026

@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

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.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread lib/test/src/promise/async.promise.test.ts Outdated
Comment thread lib/test/src/internal/timeout_helpers.test.ts Outdated
@nev21 nev21 force-pushed the nev21/NormalizeTimeout branch from 7687689 to 07c28fe Compare July 8, 2026 06:28
@nev21 nev21 enabled auto-merge (squash) July 8, 2026 06:38
@nev21 nev21 disabled auto-merge July 8, 2026 06:54
@nev21 nev21 force-pushed the nev21/NormalizeTimeout branch from 07c28fe to 3427701 Compare July 8, 2026 06:54
nevware21-bot
nevware21-bot previously approved these changes Jul 8, 2026

@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 force-pushed the nev21/NormalizeTimeout branch 2 times, most recently from 46da268 to 7260791 Compare July 9, 2026 13:44
nevware21-bot and others added 3 commits July 9, 2026 06:44
Bound the array-unwrapping loop in _normalizeTimeoutValue to 5 iterations, falling back to the default timeout if no numeric value is found within that bound. Previously a self-referential array (e.g. a[0] = a) passed as a timeout would loop forever.
@nev21 nev21 enabled auto-merge (squash) July 9, 2026 13:48

@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 efbcfb2 into main Jul 9, 2026
10 checks passed
@nev21 nev21 deleted the nev21/NormalizeTimeout branch July 9, 2026 17:31
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