Skip to content

fix: Promise .then() must ignore non-function handlers per Promises/A+ 2.2.1#509

Merged
nev21 merged 1 commit into
nevware21:mainfrom
MSNev:MSNev/NonFunc
May 20, 2026
Merged

fix: Promise .then() must ignore non-function handlers per Promises/A+ 2.2.1#509
nev21 merged 1 commit into
nevware21:mainfrom
MSNev:MSNev/NonFunc

Conversation

@MSNev
Copy link
Copy Markdown
Contributor

@MSNev MSNev commented May 18, 2026

When .then() receives a non-function, non-undefined handler, it incorrectly uses the handler value as the resolved value instead of passing through the settled value. This violates Promises/A+ spec section 2.2.1 which states that non-function handlers must be ignored.

Changes:

  • Use isFunction(handler) check instead of isUndefined(handler) to determine whether to invoke the handler or pass through the settled value
  • Use isFunction(handler) instead of truthy check to determine the resolve/ reject path for the chained promise
  • Increase idle promise test timeout from 10s to 30s to account for requestIdleCallback deferral in headless browsers

@MSNev MSNev added this to the 0.6.0 milestone May 18, 2026
@MSNev MSNev requested review from a team as code owners May 18, 2026 23:35
@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.49%. Comparing base (60a0710) to head (a95900d).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #509      +/-   ##
==========================================
- Coverage   97.56%   97.49%   -0.08%     
==========================================
  Files          27       27              
  Lines        1439     1438       -1     
  Branches      336      338       +2     
==========================================
- Hits         1404     1402       -2     
- Misses         35       36       +1     
Files with missing lines Coverage Δ
lib/src/promise/base.ts 98.98% <100.00%> (-0.26%) ⬇️
🚀 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 previously approved these changes May 19, 2026
@nev21 nev21 enabled auto-merge (squash) May 19, 2026 06:49
…+ 2.2.1

When .then() receives a non-function, non-undefined handler, it incorrectly
uses the handler value as the resolved value instead of passing through the
settled value. This violates Promises/A+ spec section 2.2.1 which states
that non-function handlers must be ignored.

Changes:
- Use isFunction(handler) check instead of isUndefined(handler) to determine
  whether to invoke the handler or pass through the settled value
- Use isFunction(handler) instead of truthy check to determine the resolve/
  reject path for the chained promise
- Increase idle promise test timeout from 10s to 30s to account for
  requestIdleCallback deferral in headless browsers
@nev21 nev21 merged commit be3361e into nevware21:main May 20, 2026
11 of 14 checks passed
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.

2 participants