Skip to content

trace_events: add node.promises category, rejection counter#22124

Closed
jasnell wants to merge 4 commits into
nodejs:masterfrom
jasnell:trace-event-promise-rejections
Closed

trace_events: add node.promises category, rejection counter#22124
jasnell wants to merge 4 commits into
nodejs:masterfrom
jasnell:trace-event-promise-rejections

Conversation

@jasnell

@jasnell jasnell commented Aug 4, 2018

Copy link
Copy Markdown
Member

Allow the trace event log to include a count of unhandled rejections
and handled after rejections. This is useful primarily as a quick
check to see if rejections may be going unhandled (and unnoticed
in a process).

These can be visualized in the Chrome trace events viewer as a stacked graph:

image

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label Aug 4, 2018
@jasnell

jasnell commented Aug 4, 2018

Copy link
Copy Markdown
Member Author

Comment thread src/bootstrapper.cc Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are these values supposed to be global? Wouldn’t something per-Node.js-instance (aka per-Environment) make more sense?

(If they are supposed to be global: You probably want std::atomic_uint64_t instead.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Currently thinking that global is the right thing for now. This is really intended as a kind of spot check... e.g. let's do a really quick check to see the ratio of unhandled rejections to handled after rejections to see if we may have a problem. I don't think we need more detail than that. +1 on std::atomic_uint64_t

@jasnell

jasnell commented Aug 6, 2018

Copy link
Copy Markdown
Member Author

@jasnell

jasnell commented Aug 6, 2018

Copy link
Copy Markdown
Member Author

/cc @nodejs/diagnostics @nodejs/promises-debugging @nodejs/trace-events

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why are these <= and not ===?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Because there are two of these that are tested, one with a value of 1 another with a value of 2.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm still confused about why it's done this way rather than two explicit checks, but won't press it

@benjamingr benjamingr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sure and LGTM, definitely sounds like something that's interesting to have in trace_events, might want to add more details about the rejections at a later PR.

@misterdjules

Copy link
Copy Markdown

Thanks @jasnell, that definitely seems useful.

One thing that seems key to make those events actionable would be to include the rejection's error's stack trace in those event log entries. I'm not familiar with trace events in Node.js, is that possible?

If that is possible, are there visualization clients that would allow to read/aggregate those stack traces (maybe Chrome)?

@alexkozy

alexkozy commented Aug 6, 2018

Copy link
Copy Markdown
Member

/cc @a1ph is expert in tracing.

@jasnell

jasnell commented Aug 6, 2018

Copy link
Copy Markdown
Member Author

Right now, collecting the stack trace would be a bit difficult, but it is doable. I'd prefer to explore that separately tho

@misterdjules

misterdjules commented Aug 6, 2018

Copy link
Copy Markdown

@jasnell

Right now, collecting the stack trace would be a bit difficult, but it is doable. I'd prefer to explore that separately tho

Absolutely, I didn't mean that this PR should consider that now, I was just asking questions out of curiosity, and providing user feedback. Thank you again for doing this :)

I'm also happy to provide feedback/use cases or anything you'd need from a user's perspective at any time in the future.

jasnell added 2 commits August 6, 2018 16:09
Allow the trace event log to include a count of unhandled rejections
and handled after rejections. This is useful primarily as a quick
check to see if rejections may be going unhandled (and unnoticed
in a process).
@jasnell jasnell force-pushed the trace-event-promise-rejections branch from 2c0a598 to 825e0d2 Compare August 6, 2018 23:22
@jasnell

jasnell commented Aug 6, 2018

Copy link
Copy Markdown
Member Author

@jasnell

jasnell commented Aug 6, 2018

Copy link
Copy Markdown
Member Author

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@jasnell

jasnell commented Aug 7, 2018

Copy link
Copy Markdown
Member Author

jasnell added a commit that referenced this pull request Aug 7, 2018
Allow the trace event log to include a count of unhandled rejections
and handled after rejections. This is useful primarily as a quick
check to see if rejections may be going unhandled (and unnoticed
in a process).

PR-URL: #22124
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
@jasnell

jasnell commented Aug 7, 2018

Copy link
Copy Markdown
Member Author

Landed in 080316b

@jasnell jasnell closed this Aug 7, 2018
targos pushed a commit that referenced this pull request Aug 11, 2018
Allow the trace event log to include a count of unhandled rejections
and handled after rejections. This is useful primarily as a quick
check to see if rejections may be going unhandled (and unnoticed
in a process).

PR-URL: #22124
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
firass111 pushed a commit to firass111/Project_node1 that referenced this pull request Apr 16, 2025
Allow the trace event log to include a count of unhandled rejections
and handled after rejections. This is useful primarily as a quick
check to see if rejections may be going unhandled (and unnoticed
in a process).

PR-URL: nodejs/node#22124
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants