Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for TracingChannel#hasSubscribers, test Node.js v22 #11

Merged
merged 1 commit into from
May 9, 2024

Conversation

tlhunter
Copy link
Member

@tlhunter tlhunter commented May 7, 2024

  • some diagnostics_channel changes landed in Node.js in diagnostics_channel: early-exit tracing channel trace methods nodejs/node#51915
    • this PR adds the TracingChannel#hasSubscribers helper method available in Node.js v22 and v20.13
    • this PR does not add the early exit functionality from that same commit
  • since this PR only implements half of the functionality in that commit we aren't fully v22 and v20.13 compatible
    • for that reason I haven't updated the README to state that we track said versions
    • I did add a note to the README about this partial jump in functionality
  • this PR also adds CI tests against Node.js v22.x
  • partially obsoletes Add early-exit to TracingChannel #10 which is a WIP that attempted to implement both

@tlhunter tlhunter added enhancement New feature or request semver-patch labels May 7, 2024
@tlhunter tlhunter requested a review from Qard May 7, 2024 20:20
@tlhunter tlhunter changed the title add support for TracingChannel#hasSubscribers add support for TracingChannel#hasSubscribers, test Node.js v22 May 7, 2024
dc.tracingChannel = function() {
const tc = tracingChannel(...arguments);

Object.defineProperty(tc, 'hasSubscribers', { // TODO: on prototype?
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you do it on the prototype by creating a throwaway TracingChannel and getting its prototype?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's just crazy enough to work

checks.js Outdated
// if there is a TracingChannel#hasSubscribers() method
// @see https://github.com/nodejs/node/pull/51915
// TODO: note that we still need to add the TC early exit from this same version
function hasTracingChannelHasSubscribersMethod() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hasSubscribers is an accessor/property, not a method.

@tlhunter tlhunter force-pushed the tlhunter/tc-has-subscribers branch 6 times, most recently from d4ab58f to 69fec35 Compare May 8, 2024 21:26
{
const fauxTrCh = dc.tracingChannel('dc-polyfill-faux');

const TracingChannel = ObjectGetPrototypeOf(fauxTrCh);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe TracingChannelPrototype or tracingChannelPrototype, or proto or something else to indicate that it's the prototype object, and not the class/constructor.

@tlhunter tlhunter force-pushed the tlhunter/tc-has-subscribers branch from 69fec35 to 64e48fd Compare May 9, 2024 15:58
@tlhunter tlhunter merged commit c1f0ebe into main May 9, 2024
40 checks passed
@tlhunter tlhunter deleted the tlhunter/tc-has-subscribers branch May 9, 2024 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request semver-minor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants