Skip to content

fix: cap unwrap depth in timeout normalization#528

Open
nev21 wants to merge 1 commit into
mainfrom
nev21/NormalizeTimeout
Open

fix: cap unwrap depth in timeout normalization#528
nev21 wants to merge 1 commit 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.80%. Comparing base (c133f5a) to head (46da268).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #528      +/-   ##
==========================================
+ Coverage   97.55%   97.80%   +0.24%     
==========================================
  Files          28       20       -8     
  Lines        1516      774     -742     
  Branches      358      195     -163     
==========================================
- Hits         1479      757     -722     
+ Misses         37       17      -20     
Files with missing lines Coverage Δ
lib/src/internal/timeout_helpers.ts 100.00% <100.00%> (ø)
lib/src/promise/asyncPromise.ts 100.00% <100.00%> (ø)

... and 26 files with indirect coverage changes

🚀 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

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.
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