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

Emphasize user code in stack traces #27553

Open
dandv opened this issue Jan 4, 2025 · 2 comments
Open

Emphasize user code in stack traces #27553

dandv opened this issue Jan 4, 2025 · 2 comments
Labels
suggestion suggestions for new features (yet to be agreed) testing related to deno test and coverage

Comments

@dandv
Copy link

dandv commented Jan 4, 2025

Creating a new issue after discussion in #24002.

I’d like to propose a feature to improve readability when working with stack traces. Currently, assertion errors generate a verbose stack trace that includes both user code and internal library or runtime code. It can be challenging to quickly locate the lines relevant to my own logic amidst calls from the Deno standard library or third-party modules.

Failed assertions would be a good start for this feature, given stack traces are gnarly enough that a flag was created to hide them.

error: AssertionError: Values are not strictly equal.


    [Diff] Actual / Expected


-   5
+   3

  throw new AssertionError(message);
        ^
    at assertStrictEquals (https://jsr.io/@std/assert/1.0.10/strict_equals.ts:66:9)
    at toBe (https://jsr.io/@std/expect/1.0.10/_matchers.ts:29:5)
    at applyMatcher (https://jsr.io/@std/expect/1.0.10/expect.ts:223:13)
    at Proxy.<anonymous> (https://jsr.io/@std/expect/1.0.10/expect.ts:233:13)
    at checkQueueAndResults (file:///home/dandv/project/tests/common.ts:187:39) ⬅️
    at Object.runMicrotasks (ext:core/01_core.js:683:26)
    at processTicksAndRejections (ext:deno_node/_next_tick.ts:59:10)
    at runNextTicks (ext:deno_node/_next_tick.ts:76:3)
    at eventLoopTick (ext:core/01_core.js:182:21)
    at async Object.<anonymous> (file:///home/dandv/project/tests/unit.test.ts:349:7) ⬅️

Proposal

– Highlight or visually distinguish user code in the stack trace, for example with a marker like ⬅️ (since bold and colors are already used)

– Either hide references to the Deno and library calls, or de-emphasize them (greyed out?) so they don’t obscure the code paths I’m actively debugging.

@dandv
Copy link
Author

dandv commented Jan 12, 2025

Proof of demand for this feature: the clean-stack package by @sindresorhus.

image

@bartlomieju bartlomieju added the suggestion suggestions for new features (yet to be agreed) label Jan 14, 2025
@bartlomieju
Copy link
Member

While I don't have a strong opinion on this one, some team members feel that these 4 frames are very popular and should be filtered out by default:

    at Object.runMicrotasks (ext:core/01_core.js:683:26)
    at processTicksAndRejections (ext:deno_node/_next_tick.ts:59:10)
    at runNextTicks (ext:deno_node/_next_tick.ts:76:3)
    at eventLoopTick (ext:core/01_core.js:182:21)

That said, this is not very high on our priority list, but we welcome contributions and will be happy to merge a PR for it.

@bartlomieju bartlomieju added the testing related to deno test and coverage label Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
suggestion suggestions for new features (yet to be agreed) testing related to deno test and coverage
Projects
None yet
Development

No branches or pull requests

2 participants