Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Better stack trace parsing in the browser #1097

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

Merged
merged 5 commits into from
Jan 4, 2022
Merged

Better stack trace parsing in the browser #1097

merged 5 commits into from
Jan 4, 2022

Conversation

flimzy
Copy link
Member

@flimzy flimzy commented Dec 28, 2021

This reimplements and expands on #658.

Getting these tests to work was a bit of a challenge, and requires an ugly hack. We don't run the standard tests against the runtime package, since the majority of that functionality in upstream is irrelevant to us. So adding tests to that package, where this new functionality lives, is meaningless by default.

Getting those tests to work is no small task, due to many unavailable symbols, etc. And making those symbols available is no small task, because the GopherJS compiler has several special cases surrounding the runtime package that prevent our overlays from being used, etc.

To work around this, we run the new tests with gopherjs test ./compiler/natives/src/runtime, which bypasses the checks for the runtime package. But it does mean we need to add one more special case for runtime, and stop checking its imports list against upstream.

In the grand scheme of things, adding one more exception to something that's already a huge special case didn't seem like that big of a deal, but maybe others disagree.

On to the functionality... This is more robust than #658 (one great reason to uses tests, to make that easy!) My browser (Chrome) actually outputs multiple formats of stack trace lines, so this new implementation tries to parse all of them.

Some of the formats omit the function name and/or file name, which I've indicated with <none> and <anonymous> in the response from runtime.Caller(). I'm not sure if that's actually a good idea, but it seemed more descriptive than simply returning the empty string, which is the only alternative that occurred to me.

With this PR merged, it should be trivial to add new stack traces (i.e. from Safari, Mozilla, wherever) and extend the parsing functionality to be more robust.

@github-actions

This comment has been minimized.

Copy link
Member

@nevkontakte nevkontakte left a comment

Choose a reason for hiding this comment

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

Note that runtime.Stack() and, by extension, runtime/debug.Stack() do not currently do stack trace parsing/formatting. This means that panic stack traces printed to the console will remain as-is.

This is not a bad thing (I personally prefer to have the original stack trace with more breadcrumbs), just making sure it matches your expectations.

compiler/natives/src/runtime/runtime_test.go Outdated Show resolved Hide resolved
compiler/natives/src/runtime/runtime_test.go Outdated Show resolved Hide resolved
circle.yml Outdated Show resolved Hide resolved
compiler/natives/src/runtime/runtime_test.go Outdated Show resolved Hide resolved
compiler/natives/src/runtime/runtime_test.go Outdated Show resolved Hide resolved
@flimzy
Copy link
Member Author

flimzy commented Dec 29, 2021

Note that runtime.Stack() and, by extension, runtime/debug.Stack() do not currently do stack trace parsing/formatting. This means that panic stack traces printed to the console will remain as-is.

This is not a bad thing (I personally prefer to have the original stack trace with more breadcrumbs), just making sure it matches your expectations.

I agree. In fact, if it were possible to encapsulate the original stack trace in the return from Caller() and Callers(), that would probably be ideal, but given the limited data type those return, that's not really an option.

@github-actions

This comment has been minimized.

@github-actions
Copy link

github-actions bot commented Jan 3, 2022

Reference app: jQuery TodoMVC (acf500a6c32a83d8c4582d967b09a65febf0e120)

BRANCH ORIGINAL MINIFIED COMPRESSED (GZIP)
Pull request (stack2) 3,199,720 bytes 2,078,377 bytes 394,127 bytes
Target branch (master) 0.05% increase (1,618 bytes) 0.05% increase (1,035 bytes) 0.07% increase (285 bytes)

#outputSize

@flimzy
Copy link
Member Author

flimzy commented Jan 3, 2022

@nevkontakte Care to take another look at the updates before I merge?

@nevkontakte
Copy link
Member

LGTM, thanks for making the changes!

@flimzy flimzy merged commit ee1fd17 into master Jan 4, 2022
@flimzy flimzy deleted the stack2 branch January 4, 2022 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.