Skip to content

refactor(microtask): setTimeout used instead of microtask queue for promise resolution #503#514

Merged
nev21 merged 1 commit into
mainfrom
nev21/useMicrotask
May 30, 2026
Merged

refactor(microtask): setTimeout used instead of microtask queue for promise resolution #503#514
nev21 merged 1 commit into
mainfrom
nev21/useMicrotask

Conversation

@nev21

@nev21 nev21 commented May 30, 2026

Copy link
Copy Markdown
Contributor
  • timeout=0/default path uses microtask scheduling (scheduleMicrotask)
  • explicit timeout>0 continues to use setTimeout(timeout)
  • fake-timer compatibility path remains setTimeout(0) for deterministic tests

@nev21 nev21 added this to the 0.6.0 milestone May 30, 2026
@nev21 nev21 requested a review from a team as a code owner May 30, 2026 05:27
Copilot AI review requested due to automatic review settings May 30, 2026 05:27
@nev21 nev21 requested a review from a team as a code owner May 30, 2026 05:27

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 refactors asynchronous promise continuation scheduling so default/zero-timeout resolution uses microtasks while preserving delayed scheduling for positive timeout values and fake-timer compatibility.

Changes:

  • Adds microtask-based scheduling to timeoutItemProcessor.
  • Introduces timeout normalization for direct and chained promise extra arguments.
  • Adds a focused microtask timing test and updates dependency lockfiles for @nevware21/ts-utils.

Reviewed changes

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

Show a summary per file
File Description
package.json Bumps @nevware21/ts-utils minimum version.
lib/package.json Bumps published package runtime dependency on @nevware21/ts-utils.
common/config/rush/npm-shrinkwrap.json Refreshes locked dependency graph.
lib/src/internal/timeout_helpers.ts Adds shared timeout normalization helper.
lib/src/promise/itemProcessor.ts Switches default async scheduling to microtasks and keeps timeout/fake-timer paths.
lib/src/promise/idlePromise.ts Uses shared timeout normalization for idle promises.
lib/test/src/promise/async.microtask.promise.test.ts Adds coverage for default microtask timing.
Files not reviewed (1)
  • common/config/rush/npm-shrinkwrap.json: Language not supported

Comment thread lib/src/internal/timeout_helpers.ts Outdated

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 6 out of 7 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • common/config/rush/npm-shrinkwrap.json: Language not supported

Comment thread common/config/rush/npm-shrinkwrap.json

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 7 out of 8 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • common/config/rush/npm-shrinkwrap.json: Language not supported

Comment thread lib/src/promise/itemProcessor.ts Outdated
@codecov

codecov Bot commented May 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.57%. Comparing base (cf2f0c6) to head (8ad3dc6).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #514      +/-   ##
==========================================
+ Coverage   97.49%   97.57%   +0.07%     
==========================================
  Files          27       28       +1     
  Lines        1438     1484      +46     
  Branches      337      350      +13     
==========================================
+ Hits         1402     1448      +46     
  Misses         36       36              
Files with missing lines Coverage Δ
lib/src/internal/timeout_helpers.ts 100.00% <100.00%> (ø)
lib/src/promise/idlePromise.ts 100.00% <100.00%> (ø)
lib/src/promise/itemProcessor.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.

@nev21 nev21 force-pushed the nev21/useMicrotask branch from a70bc65 to 8ad3dc6 Compare May 30, 2026 20:23
…romise resolution #503

- timeout=0/default path uses microtask scheduling (scheduleMicrotask)
- explicit timeout>0 continues to use setTimeout(timeout)
- fake-timer compatibility path remains setTimeout(0) for deterministic tests
@nev21 nev21 enabled auto-merge (squash) May 30, 2026 20:58

@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 69c3c29 into main May 30, 2026
10 checks passed
@nev21 nev21 deleted the nev21/useMicrotask branch May 30, 2026 21:31
Copilot AI mentioned this pull request May 31, 2026
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