GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: include `.cause` stacks in the error stack traces by voxpelli · Pull Request #4829 · mochajs/mocha

Conversation

@voxpelli

@voxpelli voxpelli commented Feb 9, 2022 •
edited by JoshuaKGoldberg
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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:

  • V8 blog post
  • My blog post describing my ponyfill + helpers for it
  • pino merging support for it: Serialize err.cause in a nice way when possible pinojs/pino-std-serializers#78

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ephys, craig-davis, WikiRik, nwalters512, and kraenhansen reacted with thumbs up emoji
All reactions
  • 👍 5 reactions
@github-actions

github-actions Bot commented Jun 10, 2022

Copy link
Copy Markdown
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!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale this has been inactive for a while... label Jun 10, 2022
@voxpelli

voxpelli commented Jun 10, 2022

Copy link
Copy Markdown
Contributor Author

Still relevant

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot removed the stale this has been inactive for a while... label Jun 13, 2022
@ephys ephys mentioned this pull request Jul 9, 2022
feat: make association definition methods throw if the generated foreign key is incompatible with an existing attribute sequelize/sequelize#14715
Draft
4 of 6 tasks
@ephys

ephys commented Sep 17, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

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.

voxpelli and craig-davis reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Jan 16, 2023

Copy link
Copy Markdown
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!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

ephys commented Jan 16, 2023

Copy link
Copy Markdown

Would still love to see this merged

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@voxpelli

voxpelli commented Jan 16, 2023

Copy link
Copy Markdown
Contributor Author

Same here

botflux reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

github-actions Bot commented May 19, 2023

Copy link
Copy Markdown
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!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

ephys commented May 19, 2023

Copy link
Copy Markdown

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

voxpelli, nwalters512, and kraenhansen reacted with heart emoji
All reactions
  • ❤️ 3 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

WikiRik commented Jun 19, 2023

Copy link
Copy Markdown

@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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@voxpelli voxpelli mentioned this pull request Jul 14, 2023
🚀 Feature: Support printing each error within AggregateErrors #4982
Open
@voxpelli voxpelli mentioned this pull request Jul 24, 2023
.cause of errors innode:test test cases not available to custom reporter nodejs/node#48900
Closed
@github-actions

github-actions Bot commented Oct 18, 2023

Copy link
Copy Markdown
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!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale this has been inactive for a while... label Oct 18, 2023
@voxpelli

voxpelli commented Oct 18, 2023

Copy link
Copy Markdown
Contributor Author

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot removed the stale this has been inactive for a while... label Oct 20, 2023
@voxpelli voxpelli mentioned this pull request Nov 3, 2023
feat: support reporting AggregateErrors #5018
Closed
@barak007

barak007 commented Dec 5, 2023

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@voxpelli
voxpelli requested a review from a team December 5, 2023 15:57
JoshuaKGoldberg
JoshuaKGoldberg requested changes Dec 5, 2023
View reviewed changes

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this 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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

WikiRik, ephys, and kraenhansen reacted with heart emoji
All reactions
  • ❤️ 3 reactions
Comment thread test/reporters/base.spec.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/reporters/base.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@barak007 barak007 mentioned this pull request Dec 25, 2023
fix: behavior/performance issues when creating error with every disposal add. dazl-dev/core3-utils#720
Merged
@JoshuaKGoldberg JoshuaKGoldberg mentioned this pull request Dec 27, 2023
🚀 Feature: Add support for outputting Error cause #2735
Closed
@voxpelli voxpelli mentioned this pull request Jan 8, 2024
fix: harden error handling in lib/cli/run.js #5074
Merged
3 tasks done
@voxpelli voxpelli self-assigned this Feb 19, 2024
@JoshuaKGoldberg JoshuaKGoldberg added the semver-minor implementation requires increase of "minor" version number; "features" label Mar 4, 2024
@voxpelli
voxpelli merged commit 3735873 into mochajs:master Mar 4, 2024
@voxpelli
voxpelli deleted the support-error-causes branch March 4, 2024 14:27
@voxpelli

voxpelli commented Mar 26, 2024

Copy link
Copy Markdown
Contributor Author

Included in v10.4.0 🎉

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@azu azu mentioned this pull request Mar 26, 2024
ES2022: Error Cause js-primer/js-primer#1714
Closed
2 tasks
@M0ng00se7169 M0ng00se7169 mentioned this pull request May 21, 2024
[Snyk] Upgrade mocha from 10.3.0 to 10.4.0 M0ng00se7169/Kickstart#83
Merged
@matrix-compute matrix-compute mentioned this pull request Jun 24, 2024
[Snyk] Upgrade mocha from 10.2.0 to 10.4.0 matrix-compute/tracker-blocklists#2
Open
@Grizzelbee Grizzelbee mentioned this pull request Jul 16, 2024
[Snyk] Upgrade mocha from 10.4.0 to 10.5.0 Grizzelbee/ioBroker.dysonairpurifier#310
Closed
@hoang3402 hoang3402 mentioned this pull request Jul 16, 2024
[Snyk] Upgrade mocha from 10.4.0 to 10.5.1 hoang3402/CodeWars#35
Closed
@tylerezimmerman tylerezimmerman mentioned this pull request Jul 16, 2024
[Snyk] Upgrade mocha from 10.4.0 to 10.5.1 DelineaXPM/SS-ADO-BuildTask#71
Merged
@tdbaine tdbaine mentioned this pull request Jul 16, 2024
[Snyk] Upgrade mocha from 10.4.0 to 10.5.1 adamw1221/CS495-Lab-Inventory-Group-F#13
Open
@M0ng00se7169 M0ng00se7169 mentioned this pull request Jul 16, 2024
[Snyk] Upgrade mocha from 10.4.0 to 10.5.1 M0ng00se7169/Kickstart#88
Open
@MaxMood96 MaxMood96 mentioned this pull request Jul 17, 2024
[Snyk] Upgrade mocha from 10.2.0 to 10.5.1 MaxMood96/node-oracledb#99
Closed
@Grizzelbee Grizzelbee mentioned this pull request Jul 18, 2024
[Snyk] Upgrade mocha from 10.1.0 to 10.5.2 Grizzelbee/ioBroker.resol#152
Closed
@SpinningRecords SpinningRecords mentioned this pull request Jul 20, 2024
[Snyk] Upgrade mocha from 10.2.0 to 10.5.2 SpinningRecords/uBlock#5
Open
@saileshvyas saileshvyas mentioned this pull request Jul 27, 2024
[Snyk] Upgrade mocha from 10.2.0 to 10.6.0 saileshvyas/Microsoft-Defender-for-Cloud#5
Open
This was referenced Jul 28, 2024
[Snyk] Upgrade mocha from 10.2.0 to 10.6.0 hashim21223445/chai#3
Closed
[Snyk] Upgrade mocha from 10.4.0 to 10.6.0 hashim21223445/chai-as-promised#1
Merged
[Snyk] Upgrade mocha from 10.3.0 to 10.6.0 hashim21223445/axios#2
Merged
This was referenced Aug 7, 2024
[Snyk] Upgrade mocha from 10.2.0 to 10.6.0 hashim21223445/broadcast-channel#7
Merged
[Snyk] Upgrade mocha from 10.3.0 to 10.7.0 hashim21223445/axios#10
Merged
[Snyk] Upgrade mocha from 10.4.0 to 10.7.0 hashim21223445/chai-as-promised#5
Merged
@MaxMood96 MaxMood96 mentioned this pull request Aug 25, 2024
[Snyk] Upgrade mocha from 10.2.0 to 10.7.0 MaxMood96/node-oracledb#102
Closed
@SapiannykSerhii SapiannykSerhii mentioned this pull request Sep 25, 2024
[Snyk] Upgrade mocha from 10.0.0 to 10.7.3 SapiannykSerhii/-NeWFestivaleWave-express_API_app#128
Open
@MaxMood96 MaxMood96 mentioned this pull request Oct 6, 2024
[Snyk] Upgrade mocha from 10.2.0 to 10.7.3 MaxMood96/node-oracledb#103
Closed
This was referenced Oct 23, 2024
[Snyk] Upgrade mocha from 9.2.2 to 10.7.3 nerdy-tech-com-gitub/preact#11
Open
[Snyk] Upgrade mocha from 9.2.2 to 10.7.3 nerdy-tech-com-gitub/node#8
Open
@HaLaGu1L HaLaGu1L mentioned this pull request Nov 1, 2024
[Snyk] Upgrade mocha from 10.1.0 to 10.7.3 HaLaGu1L/wallet-core#7
Open
@SkyeFull90 SkyeFull90 mentioned this pull request Nov 9, 2024
[Snyk] Upgrade mocha from 10.3.0 to 10.7.3 SkyeFull90/100devs-projects-skye#8
Merged
lennonnikolas pushed a commit to lennonnikolas/mocha that referenced this pull request Jan 24, 2026
@voxpelli @JoshuaKGoldberg
feat: include .cause stacks in the error stack traces (mochajs#4829)
41577d8
* Append the cause stacks to the main stack trace

It would be great to get the full error stack chain for errors with causes, especially as all current browsers and Node.js >=16 supports it, see eg https://v8.dev/features/error-cause and https://dev.to/voxpelli/pony-cause-1-0-error-causes-2l2o

Eg. `pino` merged support for this as well: pinojs/pino-std-serializers#78

* Fix tests

* Skip some string concatenation

* Don't export needlessly + improve docs

* Improved recursive filtering

* Added loop protection

* Same logic for "message" in cause trail as in top

* Apply suggestions from code review

Co-authored-by: Josh Goldberg ✨ <[email protected]>

* Revert "Apply suggestions from code review"

This reverts commit 04f7008.

---------

Co-authored-by: Josh Goldberg ✨ <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@JoshuaKGoldberg JoshuaKGoldberg JoshuaKGoldberg approved these changes
@barak007 barak007 Awaiting requested review from barak007

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@voxpelli voxpelli

Labels

semver-minor implementation requires increase of "minor" version number; "features"

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

🚀 Feature: Add support for outputting Error cause

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@voxpelli @ephys @WikiRik @barak007 @coveralls @JoshuaKGoldberg
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.