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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Bug: Browser doesn't include call stack for global uncaught errors #5106

Open
4 tasks done
JoshuaKGoldberg opened this issue Feb 28, 2024 · 1 comment 路 May be fixed by #5107
Open
4 tasks done

馃悰 Bug: Browser doesn't include call stack for global uncaught errors #5106

JoshuaKGoldberg opened this issue Feb 28, 2024 · 1 comment 路 May be fixed by #5107
Labels
area: browser browser-specific status: accepting prs Mocha can use your help with this one! type: bug a defect, confirmed by a maintainer

Comments

@JoshuaKGoldberg
Copy link
Member

JoshuaKGoldberg commented Feb 28, 2024

Bug Report Checklist

  • I have read and agree to Mocha's Code of Conduct and Contributing Guidelines
  • I have searched for related issues and issues with the faq label, but none matched my issue.
  • I have 'smoke tested' the code to be tested by running it outside the real test suite to get a better sense of whether the problem is in the code under test, my usage of Mocha, or Mocha itself.
  • I want to provide a PR to resolve this

Expected

When an uncaught error occurs during a test in browsers, you'd expect to see the call stack. That's useful.

Error: Oh no!
    at inner (test.example.js:8:15)

Actual

Mocha's browser error handling code was written before browsers gave nice stacks (eb58761).

Error: Error: Oh no! (http://127.0.0.1:8081/test.example.js:8)

Minimal, Reproducible Example

Using a minimal browser setup such as in mochajs/mocha-examples#72:

it("example", (done) => {
    function inner() {
        throw new Error("Oh no!");
    }

    setTimeout(inner);
});

Versions

Mocha: 10.3.0

Additional Info

This was filed long ago in #2167, then a fix proposed in #3952. Since #2167 is quite old, re-filing to be more current.

@ergunsh
Copy link

ergunsh commented May 6, 2024

Hey hey, thanks for noticing & working on this! We're using Mocha in Chrome DevTools and this specific feature is much needed :)

I had taken a stab to fix this in here then I realized that your PR #5107 already looks good. Are you thinking of continuing that and making it cross the finish line?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: browser browser-specific status: accepting prs Mocha can use your help with this one! type: bug a defect, confirmed by a maintainer
Projects
None yet
2 participants