Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Rewrite Error.p.stack #30908

Merged
merged 4 commits into from
Dec 15, 2023
Merged

Rewrite Error.p.stack #30908

merged 4 commits into from
Dec 15, 2023

Conversation

Josh-Cena
Copy link
Member

Fix #30906

@Josh-Cena Josh-Cena requested a review from a team as a code owner December 10, 2023 18:45
@Josh-Cena Josh-Cena requested review from chrisdavidmills and removed request for a team December 10, 2023 18:45
@github-actions github-actions bot added the Content:JS JavaScript docs label Dec 10, 2023
Copy link
Contributor

github-actions bot commented Dec 10, 2023

Preview URLs

External URLs (4)

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

(comment last updated: 2023-12-12 08:20:38)

Copy link
Contributor

@chrisdavidmills chrisdavidmills left a comment

Choose a reason for hiding this comment

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

@Josh-Cena thanks for the great work on this! It mostly makes sense; I have left a few suggestions for you to consider.

@sidewayss
Copy link
Contributor

I just came across a case where Chrome does leaves stack undefined: the clipboard. Can't create a fiddle/pen/playground because reproducing it requires setting a breakpoint on the first line of this block. That shifts focus away from the page during the copy operation, causing an error. Once it breaks, you step line-by-line (F10) a couple of times until the error is caught:

navigator.clipboard.writeText(txt)
    .then (()  => /* insert code here */; )
    .catch(err => alert(`Copy failed: ${err.stack ?? err}`));

Note the end of the last line where I fall back to err.toString() when err.stack is undefined. I just added that bit because of this behavior. Firefox does define stack here (though it's only one line deep). So would this be a Chrome bug, or simply a side-effect of not having a standard in place?

@teoli2003
Copy link
Contributor

Note that the Clipboard is a weird beast as, in Webidl, it isn't an interface but a namespace. No surprise something strange is happening with it.

Co-authored-by: Chris Mills <chrisdavidmills@gmail.com>
@Josh-Cena
Copy link
Member Author

So would this be a Chrome bug, or simply a side-effect of not having a standard in place?

More likely a bug. But the only way to tell is by sending an issue and getting their reply.

@sidewayss
Copy link
Contributor

Chrome bug for clipboard error: https://bugs.chromium.org/p/chromium/issues/detail?id=1510545

Copy link
Contributor

@chrisdavidmills chrisdavidmills left a comment

Choose a reason for hiding this comment

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

OK, updates look good, so I'm setting this to approved. Nice work @Josh-Cena!

There are just a couple more comments from me for you to check out, and a couple of updated suggestions for you to review. After that we can merge.

…k/index.md

Co-authored-by: Chris Mills <chrisdavidmills@gmail.com>
@Josh-Cena
Copy link
Member Author

LGTM

@bsmth
Copy link
Member

bsmth commented Dec 15, 2023

Thanks, all! Shall we merge this one?

@chrisdavidmills chrisdavidmills merged commit a4247f6 into mdn:main Dec 15, 2023
@chrisdavidmills
Copy link
Contributor

Thanks, all! Shall we merge this one?

Yussssss ;-)

@Josh-Cena Josh-Cena deleted the rewrite-stack branch December 15, 2023 13:49
dipikabh pushed a commit to dipikabh/content that referenced this pull request Jan 17, 2024
* Rewrite Error.p.stack

* Apply suggestions from code review

Co-authored-by: Chris Mills <chrisdavidmills@gmail.com>

* Update files/en-us/web/javascript/reference/global_objects/error/stack/index.md

* Update files/en-us/web/javascript/reference/global_objects/error/stack/index.md

Co-authored-by: Chris Mills <chrisdavidmills@gmail.com>

---------

Co-authored-by: Chris Mills <chrisdavidmills@gmail.com>
@sidewayss
Copy link
Contributor

Chrome bug for clipboard error: https://bugs.chromium.org/p/chromium/issues/detail?id=1510545

fyi - this bug is fixed and heading for release in Chrome 122. One less gap in the support for Error.prototype.stack.

@Josh-Cena
Copy link
Member Author

Great to know!

@sidewayss
Copy link
Contributor

Just got Chrome 122 and tested it to confirm that it contains the bug fix.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2025
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Content:JS JavaScript docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error.prototype.stack: non-standard but universally supported
5 participants