Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Better stack trace parsing in the browser #658
Conversation
Awesome, thanks @flimzy! This is really helpful. A test would be quite nice, so this doesn't regress, and so that it's easier to fix this again if it doesn't work on some inputs. Would it be easy for you to add one? As far as the implementation goes, LGTM if it works (which I understand it does). But it's not easy to debug without seeing sample input that it runs on. |
Also, will it work if the URL has a colon like http://localhost:8080? |
Sure, I'll try to add that (it may be the weekend before I have the time).
Yes. |
What's the best way to test this functionality? I started by adding a test in the Should I overwrite those failing tests with no-op tests, so that other package tests will run? Or is there some other mechanism I can utilize for this? |
Whatever is easiest. You don't need to place the test in You can place a small test in If it's too hard to add a test, then it's likely easier to skip adding one and fix this if it regresses. I don't want to make you go out of the way and spend a disproportionately large amount of time figuring out how this can be tested. |
I'm finally looking at this again. I would love to be able to create a simple stack-parsing method, which could be tested by passing in a string, the result of The trouble is: Where to put this function and its associated tests? I tried putting them in My next try was to put them in My next attempt was to create
I'm not sure where this leaves me. One option would be to not write this function, or the tests, in Go at all. I could write it all in pure JS. But that doesn't seem like a very Go-friendly solution, either. Any other suggestions? Or should we forgo tests on this change? |
Indeed, that's what I was hoping for.
Can you elaborate on this? This sounds like the best solution, so what's stopping it from working? |
The current implementation of
runtime.Caller()
breaks in the browser, where the stack traces contain extra:
characters in the URL. This PR corrects that deficiency, while also correcting for more complex stack traces such as this one, with two sets of parenthesis, as produced in the playground:The output of the original and new implementations can be seen on the playground here:
https://gopherjs.github.io/playground/#/Mq8kuInSui
Admittedly, knowing the filename and line number of the compiled JS isn't the most useful information, but it is still far more useful than the URL scheme and 0, when debugging :)