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

Reference for de-facto interoperable V8 Stack trace API props #38048

Merged
merged 2 commits into from
Feb 10, 2025

Conversation

Josh-Cena
Copy link
Member

Part of #37930.

I'm not documenting prepareStackTrace because (a) it's only supported by V8 (b) it's too big and complex and prone to changes.

@Josh-Cena Josh-Cena requested a review from a team as a code owner February 8, 2025 08:09
@Josh-Cena Josh-Cena requested review from sideshowbarker and hamishwillee and removed request for a team and sideshowbarker February 8, 2025 08:09
@github-actions github-actions bot added Content:JS JavaScript docs size/m [PR only] 51-500 LoC changed labels Feb 8, 2025
Copy link
Contributor

github-actions bot commented Feb 8, 2025

Preview URLs

Flaws (3)

Note! 2 documents with no flaws that don't need to be listed. 🎉

URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Error
Title: Error
Flaw count: 2

  • broken_links:
    • /en-US/docs/Glossary/serializable_object is ill cased
  • macros:
    • Macro produces link /en-US/docs/Glossary/serializable_object which is a redirect

URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/captureStackTrace
Title: Error.captureStackTrace()
Flaw count: 1

  • macros:
    • Macro produces link /en-US/docs/Web/API/console/trace which is a redirect
External URLs (4)

URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Error
Title: Error


URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack
Title: Error.prototype.stack


URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/captureStackTrace
Title: Error.captureStackTrace()


URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stackTraceLimit
Title: Error.stackTraceLimit

(comment last updated: 2025-02-10 01:37:28)

- : A non-standard V8 numerical property that limits how many stack frames to include in an error stacktrace.
- `Error.prepareStackTrace()` {{non-standard_inline}} {{optional_inline}}
- : A non-standard V8 function that, if provided by user code, is called by the V8 JavaScript engine for thrown exceptions, allowing the user to provide custom formatting for stacktraces.
- {{jsxref("Error.captureStackTrace()")}} {{non-standard_inline}}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is now https://github.com/mgaudet/proposal-error-capturestacktrace - at what point does a proposal create enough of a spec that we can start saying this is on the standards track?

Copy link
Member Author

@Josh-Cena Josh-Cena Feb 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be proposed for standards track at the February TC39 meeting. It will be standards track after its acceptance.

Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
@@ -10,7 +10,7 @@ browser-compat: javascript.builtins.Error.captureStackTrace
{{JSRef}}{{Non-standard_Header}}

> [!NOTE]
> This feature is part of the currently non-standard [V8 stack trace API](https://v8.dev/docs/stack-trace-api). However, due to compatibility reasons, it is de facto implemented by all major JavaScript engines.
> This feature is part of the non-standard [V8 stack trace API](https://v8.dev/docs/stack-trace-api). However, for compatibility reasons, it is de facto implemented by all major JavaScript engines.

The **`Error.captureStackTrace()`** static method installs stack trace information on a provided object as the [`stack`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack) property.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Josh-Cena Just remembered one more thing - somewhere here we should mention that the stacktrace is not the entire stack - its some amount that is considered relevant to users. Then cross link to say that if Error.stackTraceLimit is supported that can be used to set the max size of the returned stack.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is implied by "follows the same format as {{jsxref("Error.prototype.stack")}}". The reason I want to be handwavy about it is because Firefox doesn't support stackTraceLimit and doesn't plan to, so in FF the stack is uncustomizable anyway.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. I would have added something anyway, but your call.

Copy link
Collaborator

@hamishwillee hamishwillee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks so much for this! Approving.

@hamishwillee hamishwillee merged commit 1a6926f into mdn:main Feb 10, 2025
8 checks passed
@Josh-Cena Josh-Cena deleted the error-stack branch February 10, 2025 04:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:JS JavaScript docs size/m [PR only] 51-500 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants