Description
In lib/src/promise/base.ts (lines 92-113), when .then() receives a non-function argument for onFulfilled or onRejected, the implementation uses it as a value rather than ignoring it per the Promise/A+ spec.
Per the spec (section 2.2.1): ""If onFulfilled is not a function, it must be ignored"" — meaning the promise should pass through the resolved value unchanged.
Impact
Code that relies on .then(null, errorHandler) or .then(nonFunction) patterns may behave incorrectly:
- Non-function values could be treated as resolved values
- Promise chains may not properly propagate values through identity handlers
Steps to Reproduce
javascript const p = createAsyncPromise(resolve => resolve(42)); p.then(null).then(v => { console.log(v); // Should be 42 (identity pass-through), may not be });
Suggested Fix
Check typeof onFulfilled === 'function' before invoking; if not a function, use identity function v => v. Same for onRejected with reason => { throw reason; }.
Severity
High — violates Promise/A+ spec section 2.2.1, may cause silent data loss in promise chains.
Description
In
lib/src/promise/base.ts(lines 92-113), when.then()receives a non-function argument foronFulfilledoronRejected, the implementation uses it as a value rather than ignoring it per the Promise/A+ spec.Per the spec (section 2.2.1): ""If onFulfilled is not a function, it must be ignored"" — meaning the promise should pass through the resolved value unchanged.
Impact
Code that relies on
.then(null, errorHandler)or.then(nonFunction)patterns may behave incorrectly:Steps to Reproduce
javascript const p = createAsyncPromise(resolve => resolve(42)); p.then(null).then(v => { console.log(v); // Should be 42 (identity pass-through), may not be });Suggested Fix
Check
typeof onFulfilled === 'function'before invoking; if not a function, use identity functionv => v. Same foronRejectedwithreason => { throw reason; }.Severity
High — violates Promise/A+ spec section 2.2.1, may cause silent data loss in promise chains.