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

Align paths in traces #22575

Closed
piranna opened this issue Aug 29, 2018 · 18 comments
Closed

Align paths in traces #22575

piranna opened this issue Aug 29, 2018 · 18 comments
Labels
feature request Issues that request new features to be added to Node.js. stale

Comments

@piranna
Copy link
Contributor

piranna commented Aug 29, 2018

When an exception is thrown or when using console.trace(), files paths are not aligned making it difficult to follow them at naked eye and specially to identify when it's one of your files, one internal module of if it's a file located inside node_modules folder:

UnhandledPromiseRejectionWarning: SyntaxError: Identifier 'body' has already been declared
     at Test.Runnable (/opt/app/node_modules/mocha/lib/runnable.js:36:25)
     at new Test (/opt/app/node_modules/mocha/lib/test.js:24:12)
     at context.it.context.specify (/opt/app/node_modules/mocha/lib/interfaces/bdd.js:85:18)
     at Function.context.it.only (/opt/app/node_modules/mocha/lib/interfaces/bdd.js:96:46)
     at Object.<anonymous> (/opt/app/src/modules/templates/template.spec.js:21:4)
     at Module._compile (internal/modules/cjs/loader.js:689:30)
     at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
     at Module.load (internal/modules/cjs/loader.js:599:32)
     at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
     at Function.Module._load (internal/modules/cjs/loader.js:530:3)
     at Module.require (internal/modules/cjs/loader.js:637:17)
     at require (internal/modules/cjs/helpers.js:20:18)
     at /opt/app/node_modules/mocha/lib/mocha.js:250:27
     at Array.forEach (<anonymous>)
     at Mocha.loadFiles (/opt/app/node_modules/mocha/lib/mocha.js:247:14)
     at Mocha.run (/opt/app/node_modules/mocha/lib/mocha.js:576:10)

Not sure if this is done at v8 level, but my proposal is to add spaces between the function name and the file paths so this last ones gets aligned between themselves to the longest one. In the previous trace, it would get like:

UnhandledPromiseRejectionWarning: SyntaxError: Identifier 'body' has already been declared
     at Test.Runnable                 (/opt/app/node_modules/mocha/lib/runnable.js:36:25)
     at new Test                      (/opt/app/node_modules/mocha/lib/test.js:24:12)
     at context.it.context.specify    (/opt/app/node_modules/mocha/lib/interfaces/bdd.js:85:18)
     at Function.context.it.only      (/opt/app/node_modules/mocha/lib/interfaces/bdd.js:96:46)
     at Object.<anonymous>            (/opt/app/src/modules/templates/template.spec.js:21:4)
     at Module._compile               (internal/modules/cjs/loader.js:689:30)
     at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
     at Module.load                   (internal/modules/cjs/loader.js:599:32)
     at tryModuleLoad                 (internal/modules/cjs/loader.js:538:12)
     at Function.Module._load         (internal/modules/cjs/loader.js:530:3)
     at Module.require                (internal/modules/cjs/loader.js:637:17)
     at require                       (internal/modules/cjs/helpers.js:20:18)
     at                                /opt/app/node_modules/mocha/lib/mocha.js:250:27
     at Array.forEach                 (<anonymous>)
     at Mocha.loadFiles               (/opt/app/node_modules/mocha/lib/mocha.js:247:14)
     at Mocha.run                     (/opt/app/node_modules/mocha/lib/mocha.js:576:10)

There would be problems if some code is parsing the trace output taking in consideration to be just only a space between the function name and the file path instead of several spaces, so this change would need to be in a major version, but anyway exception traces are not standard and such libs are very few and mostly for debuging purposses so their impact will be low, and is a small change that they would be easily added.

@addaleax addaleax added the feature request Issues that request new features to be added to Node.js. label Aug 29, 2018
@addaleax
Copy link
Member

addaleax commented Sep 2, 2018

Not sure who to talk to here. @nodejs/v8 maybe? (edit: Sorry, I thought we had a TC39 team.)

@ryzokuken
Copy link
Contributor

@piranna @addaleax did we follow up on this? If not, I could start a discussion on the TC39 mailing list and CC you.

@piranna
Copy link
Contributor Author

piranna commented Oct 28, 2018

No, I didn't. Please start the discussion at TC39. Don't know if it's of their competence or v8 or Node.js, but I think if so TC39 would prefer instead to define a standard traces spec... At least this change would be a start for that :-)

@hashseed
Copy link
Member

You could easily achieve this by overriding Error.prepareStackTrace. I don't think we want to add the complexity for this in V8, especially since this is very bikesheddy.

@piranna
Copy link
Contributor Author

piranna commented Oct 28, 2018

Maybe would makes sense to implement this here in Node.js? Later it could be used as a proof-of-concept to implement it in other environments... Would you accept a pull-request for this?

@devsnek
Copy link
Member

devsnek commented Oct 29, 2018

@piranna i'm in the middle of rewriting our error stack decoration over in #23926. after that lands you could open a pr modifying the new stack decoration method we use.

fair warning though, i don't think many people will be partial to the format you're proposing. most people don't have enough screen real-estate for it to be practical. this seems like its better suited to happen in userland with Error.prepareStackTrace, as hashseed said.

There is also https://github.com/tc39/proposal-error-stacks

@piranna
Copy link
Contributor Author

piranna commented May 21, 2019

Now that #23926 has landed in master, can we start moving this? :-) Where should we start?

@srl295
Copy link
Member

srl295 commented Jul 16, 2019

@piranna just triaging here…

@piranna
Copy link
Contributor Author

piranna commented Jul 16, 2019

Done at tc39/proposal-error-stacks#30.

  • "you could open a pr modifying the new stack decoration method we use."

Are you propossing that I implement it on Node.js code and create a pull-request with my changes?

@github-actions
Copy link
Contributor

There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment.

For more information on how the project manages feature requests, please consult the feature request management document.

@github-actions github-actions bot added the stale label Feb 28, 2022
@piranna
Copy link
Contributor Author

piranna commented Feb 28, 2022

How can we move this forward? Maybe a PR implementing it here? I was asked to open one on tc-39 and got already stalled there...

@github-actions github-actions bot removed the stale label Mar 4, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Sep 1, 2022

There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment.

For more information on how the project manages feature requests, please consult the feature request management document.

@github-actions github-actions bot added the stale label Sep 1, 2022
@piranna
Copy link
Contributor Author

piranna commented Sep 1, 2022

Any update on this? How can we move it forward?

@github-actions github-actions bot removed the stale label Sep 2, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2023

There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment.

For more information on how the project manages feature requests, please consult the feature request management document.

@github-actions github-actions bot added the stale label Mar 2, 2023
@piranna
Copy link
Contributor Author

piranna commented Mar 2, 2023

Any update on this?

@github-actions github-actions bot removed the stale label Mar 3, 2023
@github-actions
Copy link
Contributor

There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment.

For more information on how the project manages feature requests, please consult the feature request management document.

@github-actions github-actions bot added the stale label Aug 31, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Oct 1, 2023

There has been no activity on this feature request and it is being closed. If you feel closing this issue is not the right thing to do, please leave a comment.

For more information on how the project manages feature requests, please consult the feature request management document.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 1, 2023
@piranna
Copy link
Contributor Author

piranna commented Oct 1, 2023

I still would like this to be considered, how can we proceed? Maybe I can do a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js. stale
Projects
None yet
Development

No branches or pull requests

6 participants