Description
In lib/src/promise/itemProcessor.ts (lines 44-49), the item processor uses setTimeout for scheduling promise resolution callbacks instead of the microtask queue (queueMicrotask or Promise.resolve().then()).
Impact
- Promise resolution ordering does not match native Promise behavior
- Promises resolve in a later macrotask instead of the current microtask checkpoint
- Code that depends on microtask timing (common in async coordination patterns) may exhibit race conditions
- Performance penalty from unnecessary event loop round-trips
Steps to Reproduce
javascript console.log('1'); createAsyncPromise(resolve => resolve()).then(() => console.log('3')); console.log('2'); // Native: 1, 2, 3 // With setTimeout: 1, 2, (delay), 3
Suggested Fix
Use queueMicrotask when available, falling back to Promise.resolve().then() or MutationObserver trick, before falling back to setTimeout.
Severity
Medium — timing difference from spec; may cause subtle ordering bugs in applications that depend on microtask semantics.
Description
In
lib/src/promise/itemProcessor.ts(lines 44-49), the item processor usessetTimeoutfor scheduling promise resolution callbacks instead of the microtask queue (queueMicrotaskorPromise.resolve().then()).Impact
Steps to Reproduce
javascript console.log('1'); createAsyncPromise(resolve => resolve()).then(() => console.log('3')); console.log('2'); // Native: 1, 2, 3 // With setTimeout: 1, 2, (delay), 3Suggested Fix
Use
queueMicrotaskwhen available, falling back toPromise.resolve().then()orMutationObservertrick, before falling back tosetTimeout.Severity
Medium — timing difference from spec; may cause subtle ordering bugs in applications that depend on microtask semantics.