Skip to content

refactor(timer): centralize microtask types and queueMicrotask access; expand nextTick and microtask coverage#576

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

refactor(timer): centralize microtask types and queueMicrotask access; expand nextTick and microtask coverage#576
nev21 merged 1 commit into
mainfrom
nev21/nextTick

Conversation

@nev21

@nev21 nev21 commented May 29, 2026

Copy link
Copy Markdown
Contributor
  • move MicrotaskFn and ScheduleMicrotaskFn from microtask.ts to types.ts
  • move getQueueMicrotask and hasQueueMicrotask from microtask.ts to environment.ts
  • update exports in index.ts to expose moved APIs from their new modules
  • update internal imports across timer microtask modules and nextTick to use shared helper types/environment access
  • update scheduleNextTick in nextTick.ts to prefer process.nextTick, then queueMicrotask, then existing fallback resolution
  • add internal queue scheduler helper in microtaskQueue.ts
  • extend tests in microtask.test.ts for internal microtask queue rescheduling behavior
  • extend tests in nextTick.test.ts for Promise fallback ordering and no-Promise/no-microtask edge scenarios
  • align nextTick tests to explicitly disable queueMicrotask where Promise/timer fallback behavior is being validated

@nev21 nev21 added this to the 0.15.0 milestone May 29, 2026
@nev21 nev21 requested review from a team as code owners May 29, 2026 20:54
Copilot AI review requested due to automatic review settings May 29, 2026 20:54
@codecov

codecov Bot commented May 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.17%. Comparing base (87cb303) to head (8247d96).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
lib/src/timer/microtasks/microtaskQueue.ts 94.64% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #576      +/-   ##
==========================================
- Coverage   99.35%   99.17%   -0.18%     
==========================================
  Files         165      179      +14     
  Lines        5089     5475     +386     
  Branches     1116     1200      +84     
==========================================
+ Hits         5056     5430     +374     
- Misses         33       45      +12     
Files with missing lines Coverage Δ
lib/src/helpers/environment.ts 97.84% <100.00%> (-0.95%) ⬇️
lib/src/helpers/types.ts 100.00% <ø> (ø)
lib/src/timer/microtask.ts 100.00% <100.00%> (ø)
lib/src/timer/microtasks/cancellableTask.ts 96.42% <100.00%> (ø)
lib/src/timer/microtasks/processNextTick.ts 100.00% <100.00%> (ø)
lib/src/timer/microtasks/promiseQueue.ts 95.45% <100.00%> (ø)
lib/src/timer/microtasks/resolveScheduleFn.ts 100.00% <100.00%> (ø)
lib/src/timer/microtasks/runMicrotask.ts 100.00% <100.00%> (ø)
lib/src/timer/nextTick.ts 98.52% <100.00%> (+0.02%) ⬆️
lib/src/timer/microtasks/microtaskQueue.ts 94.64% <94.64%> (ø)

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

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

Pull request overview

Centralizes microtask-related types and the queueMicrotask accessor into shared helper modules, threads them through the timer subsystem, updates scheduleNextTick to prefer queueMicrotask after process.nextTick, adds a new internal queue-batched microtask scheduler, and extends test coverage for fallback ordering and queue semantics.

Changes:

  • Move MicrotaskFn/ScheduleMicrotaskFn to helpers/types.ts and getQueueMicrotask/hasQueueMicrotask to helpers/environment.ts; re-point internal imports and root exports accordingly.
  • Update scheduleNextTick to fall back through queueMicrotask between process.nextTick and the Promise/timer paths, plus add a new _getMicrotaskQueueFn batching helper in microtaskQueue.ts.
  • Expand microtask/nextTick tests to cover queueMicrotask batching across queue types and Promise/timer-fallback ordering scenarios.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
lib/src/helpers/types.ts Adds MicrotaskFn and ScheduleMicrotaskFn type aliases.
lib/src/helpers/environment.ts Adds getQueueMicrotask / hasQueueMicrotask exports.
lib/src/index.ts Re-exports the moved types and environment helpers from their new modules.
lib/src/timer/microtask.ts Removes the moved types/accessors and imports them from new locations.
lib/src/timer/nextTick.ts Adds queueMicrotask to the fallback chain and updates TSDoc.
lib/src/timer/microtasks/microtaskQueue.ts New helper batching queueMicrotask calls per queue type.
lib/src/timer/microtasks/{cancellableTask,processNextTick,promiseQueue,resolveScheduleFn,runMicrotask}.ts Repoint type imports to helpers/types.
lib/test/src/common/timer/microtask.test.ts Adds coverage for _getMicrotaskQueueFn rescheduling and queue-type ordering.
lib/test/src/common/timer/nextTick.test.ts Disables queueMicrotask in fallback paths and adds Promise/timer-fallback ordering tests.

Comment thread lib/src/timer/nextTick.ts Outdated
Comment thread lib/src/timer/microtasks/microtaskQueue.ts Outdated
Comment thread lib/src/timer/microtasks/microtaskQueue.ts Outdated
Comment thread lib/test/src/common/timer/nextTick.test.ts Outdated
Comment thread lib/src/timer/microtasks/microtaskQueue.ts
nevware21-bot
nevware21-bot previously approved these changes May 29, 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
Contributor

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

Comment thread lib/test/src/common/timer/nextTick.test.ts
@nev21 nev21 force-pushed the nev21/nextTick branch from 47e014c to e21767d Compare May 30, 2026 02:14
@nev21 nev21 enabled auto-merge (squash) May 30, 2026 02:14
@nev21 nev21 force-pushed the nev21/nextTick branch from e21767d to a4c7711 Compare May 30, 2026 02:51
@nev21 nev21 requested a review from Copilot May 30, 2026 03:00

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

Pull request overview

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

Comment thread lib/src/timer/microtask.ts Outdated
…; expand nextTick and microtask coverage

- move MicrotaskFn and ScheduleMicrotaskFn from microtask.ts to types.ts
- move getQueueMicrotask and hasQueueMicrotask from microtask.ts to environment.ts
- update exports in index.ts to expose moved APIs from their new modules
- update internal imports across timer microtask modules and nextTick to use shared helper types/environment access
- update scheduleNextTick in nextTick.ts to prefer process.nextTick, then queueMicrotask, then existing fallback resolution
- add internal queue scheduler helper in microtaskQueue.ts
- extend tests in microtask.test.ts for internal microtask queue rescheduling behavior
- extend tests in nextTick.test.ts for Promise fallback ordering and no-Promise/no-microtask edge scenarios
- align nextTick tests to explicitly disable queueMicrotask where Promise/timer fallback behavior is being validated
@nev21 nev21 force-pushed the nev21/nextTick branch from a4c7711 to 8247d96 Compare May 30, 2026 03:16
@nev21 nev21 disabled auto-merge May 30, 2026 03:22
@nev21 nev21 enabled auto-merge (squash) May 30, 2026 03:22

@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 358d5d1 into main May 30, 2026
10 checks passed
@nev21 nev21 deleted the nev21/nextTick branch May 30, 2026 03:30
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