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

feat: include .cause stacks in the error stack traces #4829

Merged
merged 9 commits into from
Mar 4, 2024

Conversation

voxpelli
Copy link
Member

@voxpelli voxpelli commented Feb 9, 2022

Requirements

  • Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.
  • All new code requires tests to ensure against regressions.

Description of the Change

Appends the full error stack chain for errors with causes.

Alternate Designs

Prior to the Error cause standardization, there was VError which I did a PR for supporting some years ago #2381. That one as primarily closed because an aversion to supporting random module hooks, which this now being a standard changes.

So I think this is now more a matter of:

  • Should this be on by default?
  • How should this be formatted?

Why should this be in core?

All current browsers supports this property and Node.js as well since 16.x.

See also eg:

Benefits

Error causes are a great way to enrich errors and to ensure that one can catch all relevant places across an async workflow. See also eg. this old Joyent article explaining how they uses VError.

Possible Drawbacks

  • It can become a bit too verbose if a lot of unnecessary causes gets printed, but is that an issue to take into consideration here?

Applicable issues

  • This would be a breaking change for everyone that relies on specific stack output for current error object's containing a stack possessing cause property, else it would be a minor. So depends on whether the specific stack output is seen as an API that should be stable or whether it's simply a presentation detail.

Fixes #2735.

@github-actions
Copy link
Contributor

This PR hasn't had any recent activity, and I'm labeling it stale. Remove the label or comment or this PR will be closed in 14 days. Thanks for contributing to Mocha!

@github-actions github-actions bot added the stale this has been inactive for a while... label Jun 10, 2022
@voxpelli
Copy link
Member Author

Still relevant

@ephys
Copy link

ephys commented Sep 17, 2022

This PR looks good to me. We'd love for this to land. We had to implement some workarounds in the https://github.com/sequelize/sequelize test suites because our own error messages make heavy use of the cause property and the lack of support for them made them difficult to debug.

@github-actions
Copy link
Contributor

This PR hasn't had any recent activity, and I'm labeling it stale. Remove the label or comment or this PR will be closed in 14 days. Thanks for contributing to Mocha!

@github-actions github-actions bot added the stale this has been inactive for a while... label Jan 16, 2023
@ephys
Copy link

ephys commented Jan 16, 2023

Would still love to see this merged

@voxpelli
Copy link
Member Author

Same here

@github-actions github-actions bot removed the stale this has been inactive for a while... label Jan 18, 2023
@github-actions
Copy link
Contributor

This PR hasn't had any recent activity, and I'm labeling it stale. Remove the label or comment or this PR will be closed in 14 days. Thanks for contributing to Mocha!

@github-actions github-actions bot added the stale this has been inactive for a while... label May 19, 2023
@ephys
Copy link

ephys commented May 19, 2023

Labeling someone's work as stale because you haven't had time to review is not great :/

@github-actions github-actions bot removed the stale this has been inactive for a while... label May 22, 2023
@WikiRik
Copy link

WikiRik commented Jun 19, 2023

@juergba would be great if you could take a look at this. Node 16 is the oldest still supported version of Node so there are no supported versions anymore that do not have Error.cause

@github-actions
Copy link
Contributor

This PR hasn't had any recent activity, and I'm labeling it stale. Remove the label or comment or this PR will be closed in 14 days. Thanks for contributing to Mocha!

@github-actions github-actions bot added the stale this has been inactive for a while... label Oct 18, 2023
@voxpelli
Copy link
Member Author

Still a lack of review, not this PR itself being stale

@github-actions github-actions bot removed the stale this has been inactive for a while... label Oct 20, 2023
@barak007
Copy link

barak007 commented Dec 5, 2023

Is this going to be merged? we want to start using the cause field in our errors.

@voxpelli voxpelli requested a review from a team December 5, 2023 15:57
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

🚀 excited to see cause support finally land!

We looked at this as a group, agreed with the general direction. Just a bit of edge case handling needed.

test/reporters/base.spec.js Outdated Show resolved Hide resolved
lib/reporters/base.js Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-minor implementation requires increase of "minor" version number; "features"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🚀 Feature: Add support for outputting Error cause
6 participants