Skip to content

diagnostics_channel: add iterator support to tracing channel#61686

Open
rochdev wants to merge 4 commits intonodejs:mainfrom
rochdev:trace-generator
Open

diagnostics_channel: add iterator support to tracing channel#61686
rochdev wants to merge 4 commits intonodejs:mainfrom
rochdev:trace-generator

Conversation

@rochdev
Copy link
Contributor

@rochdev rochdev commented Feb 5, 2026

Most tracing channel use cases can already be handled by a combination of traceSync, tracePromise and traceCallback. However, functions returning an iterator need the iterator to also be instrumented. This is because for the operation executed by the function to actually be done the iterator needs to reach its done state, and to collect the result the chunks from each iteration must be available.

This PR adds support for a new traceIterator function that wraps a function returning an iterator so that both the function and every iterator iterations are traced.

Open question:

  • Should traceIterator just wrap iterators and not functions? This would deviate from other traceX methods but would remove the need to handle sync and async with the same function.
    • Is it even desirable to handle only one type of return value at a time? The current API is often unusable because of this and the underlying code must be duplicated instead. Maybe it would be better to have tracing methods be able to handle more not less?
    • For example, should tracePromise also handle synchronous return values similar to the new #traceMaybePromise? Right now it converts to a promise, which may incorrectly change the return type.

@nodejs-github-bot nodejs-github-bot added diagnostics_channel Issues and PRs related to diagnostics channel needs-ci PRs that need a full CI run. labels Feb 5, 2026
@rochdev rochdev changed the title diagnostics_channel: add generator support to tracing channel diagnostics_channel: add iterator support to tracing channel Mar 9, 2026
@rochdev rochdev marked this pull request as ready for review March 9, 2026 22:29
@codecov
Copy link

codecov bot commented Mar 10, 2026

Codecov Report

❌ Patch coverage is 91.25000% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.65%. Comparing base (8c32389) to head (46b889a).
⚠️ Report is 233 commits behind head on main.

Files with missing lines Patch % Lines
lib/diagnostics_channel.js 91.25% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #61686      +/-   ##
==========================================
- Coverage   89.75%   89.65%   -0.10%     
==========================================
  Files         674      676       +2     
  Lines      204394   206626    +2232     
  Branches    39278    39560     +282     
==========================================
+ Hits       183448   185248    +1800     
- Misses      13238    13492     +254     
- Partials     7708     7886     +178     
Files with missing lines Coverage Δ
lib/diagnostics_channel.js 97.95% <91.25%> (-1.15%) ⬇️

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

diagnostics_channel Issues and PRs related to diagnostics channel needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants