-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
intent to implement - rework of stack trace decoration #21958
Comments
Is there a v8 issue related to the patch specifically? I see related issues but not one specifically for adding |
@jdalton it doesn't expose anything on the js side, it's a C++ API. I just wrote the example in js for simplicity. Also there are I think two bugs associated with that patch, they should be listed in the commit message. |
I saw those, I'm looking for one specifically for the new API the patch is introducing (I'm not seeing any way to provide feedback and a issue specifically for it would be a way). Is the plan to eventually expose this API on the |
@jdalton there's https://github.com/tc39/proposal-error-stacks and my example above leaves Error.prepareStackTrace intact. I would consider explicitly enabling userland here out of scope, as this is engine-specific. |
If the goal is to remove the existing way of decorating errors then I'd ask that we consider exposing a way for users to customize decorating. This could be with a symbol much like |
@jdalton i think your concerns seem better suited for tc39/proposal-error-stacks#20. the solution to your problem shouldn't be node+v8-specific. |
I'm not a fan of removing/changing the existing functionality without a user-land path. Does the V8 patch and intent to rework stack trace decoration require on the |
@jdalton no - this proposal changes nothing to userland except that more errors will have decorated stacks. the same APIs that you would have used (such as Error.prepareStackTrace) exist in the same way and are actually safer to use because node won't decorate your stacks. |
As we progress it would be rad to start thinking about possible util APIs (symbol, etc.) that developers can use to signal that their error stack is already decorated to avoid being re-decorated by Node. Currently there is a pseudo private way (that you're familiar with), but as we move away from that internally it would be great to provide a proper path for users here. |
with this proposed change, that is fixed.
IMO the way to move with that is do the proposed System.getStack and generate the string and then just set |
Can you dig into how it's fixed a bit more. How is it decoration detected? |
@jdalton you don't have to detect it. With this change if |
Ah, I don't know if that's granular enough. Currently, user-land can mark one error as decorated and let others pass through without decoration (to be decorated by Node). If we use Update: Can you provide a usage example. Maybe that would clear things up. |
@jdalton if you're alluding to performing decoration where we just take a stack string and modify it, i don't think its worth supporting in this case. There are plenty of cases already where an error is decorated by not-node and has no arrow symbol or an error has an arrow symbol but was not decorated because it slipped through For the moment the safe way to decorate a stack is: const { prepareStackTrace } = Error;
Error.prepareStackTrace = (error, frames) => { ... };
myError.stack; // trigger pesudo-getter
Error.prepareStackTrace = prepareStackTrace |
If I break down your example you're saying that with the proposed approach Node will use the prepare callback to intercept the builtin If I hold on to the builtin |
@jdalton I agree that Error.prepareStackTrace is not ideal, and that userland should have better ways of making errors their own. However again i'm trying very hard to not introduce any new semantics here or change existing ones. This is designed to be more or less invisible to userland. I don't want to step on the toes of the ecma262 stack proposal. if you want we can run an analsys over npm and see how many people are using process.binding('util')'s hidden properties but it is terrible and i don't think its a case we need to support. |
Cool!
Just as Node allows customizing object inspection with |
@jdalton but as soon as we start to discuss implementation it gets hairy because i don't agree that symbols on errors is the right way to do this, even if i was interested in adding a new feature here. We can always discuss adding things later. I really just want to discuss the changes i outlined originally, with adding new APIs being out of scope. |
That's cool too. Start noodling on it. Any intent to rework Node's trace decoration should keep user-land customization in mind is all. |
cc @nodejs/diagnostics as I believe this might be of our interest as well. |
Note that V8 currently doesn't expose a default |
This is an attempt to finally fix the inconsistent stack decoration in node core... hopefully future-facing enough for everyone.
the final code might not be js but the logic will look something like this:
i have a patch here (https://chromium-review.googlesource.com/c/v8/v8/+/1119768) to implement the API callback in V8 (and after that lands I have another patch lined up to make v8::StackTrace movable to js-land) but before any of that happens V8 wants to know we will actually use this.
The only thing not handled here is when node has an uncaught non-error exception:
node/src/node.cc
Lines 976 to 985 in 811598b
/cc @hashseed @schuay @addaleax @Trott
The text was updated successfully, but these errors were encountered: