-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Better stacktrace data for non-file routes behind login wall #8656
Comments
Routing to @getsentry/product-owners-issues for triage ⏲️ |
I'm going to write down some thoughts here after reading the issue and doing some research. Feel free to correct whatever is wrong but to me the following things are important:
|
I'd do this with an opt-in integration, since not all applications have this setup. For those who do, they can pay the extra bundle size cost. |
@tavisatjane I opened #8670 to collect the source context in browser. Feel free to check out the PR. We'll release this soon in version 7.61.0. You'll need to add it as an integration form import { ContextLines } from '@sentry/integrations';
Sentry.init({
// rest of your config
integrations: [new ContextLines(), /* other integrations */]
}); |
Reopening this because we discovered a lot of limitations and problems with this intergation. We'll sync how to proceed here but to unblock our next release, I had to revert the PR. More context: #8680 |
I'll leave some notes in this reply around possible approaches towards getting reliable context lines and their limitations. TL;DR: There's no reliable way to capture the raw HTML that was served to the browser and sometimes, that's not even desireable. This also applies to how Bugsnag are currently obtaining context lines and they're facing the same limitations. Option 1 - Accessing HTML via browser APIsBrowsers provide certain APIs with which we can access processed versions of the page's HTML. For example, What's important to understand with these APIs is that they will not return raw HTML that was served to the browser but a processed version that can significantly differ from the raw source. This means that the processed HTML's line numbers are very likely not in line with the stack frames' line numbers. Simple example: <!DOCTYPE html>
<html>
<body>
<button id="inline-error-btn" onclick="throw new Error('Error with context lines')">Click me</button>
</body>
</html> is returned by [
"<html><head></head><body>",
" ",
" <button id=\"inline-error-btn\" onclick=\"throw new Error('Error with context lines')\">Click me</button>"
" ",
"",
"</body></html>",
] If this button was clicked in the browser, the stack frame's line number is 7. However, the index of the processed html lines would be 2 (i.e. line number 3). We can account for some of these modified lines by shifting the beginning of the returned array back a few elements. However, as soon as users or frameworks add arbitrary line breaks, for instance between Browser differences:
Option 2: Accessing HTML by re-fetching the pageWhile event processors shouldn't be async, we could also try to fetch the HTML page again with
DecisionFor the time being, our approach will be to rely on the browser's processed HTML and keep things simple and best-effort. We can revisit this; perhaps add option 2 and use option 1 as a fallback if the request fails. I just want to point out that there's not going to be a perfect solution to this and the limitations mentioned in this post and in #8670 will still apply. Furthermore, as already mentioned, bugsnag is also accessing processed HTML, so they're confronted with the same limitations. |
Submitting on behalf of a customer (see linked Jira ticket for customer-specific details):
Problem Statement
In some cases of the same issue, stack traces have rich context, but in other cases, there is no context. The pages in question involve HAML
Example A (already behaves how we want)
URL:
http://some-client.myexamplesite.com/admin
:When we visit the actual URL and look at the page source, we can see that line 289 is present and matches the source context shown in Sentry:
Great -- this is what we want.
Example B (want different behavior)
URL:
http://another-client.myexamplesite.com/admin
:When we visit the actual URL and look at the page source, we see that line 407, where the error occurred, does not exist:
The desired behavior is to have similar detailed source context even for errors behind login walls.
Why this happens
I and colleague @Prithvirajkumar spoke internally to @kamilogorek on Slack, who mentioned that the problem with the missing stack trace is that the captured error is pointing to a route, in the case of the example it’s /admin.
Solution Brainstorm
Our customer writes:
The customer also provided this screenshot from Bugsnag:
The ideal situation would be to have stack trace information shown even for errors occurring behind login-walled routes, such as
/admin
in the example.This could require capturing and including stacktrace data at the time of the crash rather than scraping the page and encountering the login wall.
Product Area
Issues
┆Issue is synchronized with this Jira Improvement by Unito
The text was updated successfully, but these errors were encountered: