-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[rust] Capture Rust backtrace in case of error (displayed at DEBUG level) #12852
Conversation
Do we want to add |
Yes, we can do that. Many times, the backtrace might not be necessary since many of the possible errors are easily traceable. But for errors like |
but we're only getting the backtrace if there's an error? Or do we get them even when we rescue the error? |
I added a new commit to this PR to include the argument Regarding your questions:
The backtrace will be only captured when there is an unrecoverable error and the Correct operation of SM. Even if
Error in SM. When
Error in SM. Without
|
Codecov ReportAll modified lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## trunk #12852 +/- ##
=======================================
Coverage 56.51% 56.51%
=======================================
Files 86 86
Lines 5255 5255
Branches 187 187
=======================================
Hits 2970 2970
Misses 2098 2098
Partials 187 187 ☔ View full report in Codecov by Sentry. |
Having said that, the use of
|
I don't know why I wouldn't always want to know the error when |
I agree with @titusfortner. If we get an error, we should add the stack trace (or backtrace). I do not see the need for a new flag. |
I added the So, I did it that way. That change is already part of the PR, so no I continue working on this. Yesterday, I discovered that |
I continued working in this PR to capture the backtrace by default if error. But applied to #12828, I discovered that for capturing the backtrace, the debug symbols need to be included in the release artifacts, and the strip optimization needs to be removed (see modified Cargo.toml): The problem with this change is the size of the resulting binaries. It is nothing in Windows, but a lot in macOS, and especially Linux. The resulting binaries with debug symbols are as follows (see workflow): selenium-manager_linux-x64 58.1 MB This size increase is not acceptable, IMO, since we are just trying to add a better troubleshooting mechanism (which is not required in many cases). My recommendation is the following. Since we already have the PR for capturing the backtrace, let's merge it, just in case. It will not work by default, and to enable it, we need to do the following:
We will only use it for troubleshooting rare cases (like |
Wow, right, we don't want those sizes. Would it make sense to generate both standard and Debug binaries in the github action? |
Generating both types of binaries sounds like a good idea. Where would we leave the debug ones? |
If it's only for troubleshooting, we can probably just leave them on GH, but have easy access to it when needed— https://github.com/SeleniumHQ/selenium/actions/workflows/build-selenium-manager.yml?query=branch%3Atrunk |
Generating the debug SM binaries in GH Actions is a good idea. I have created a new feature request to track this: #12887. |
So the code for this PR won't be used in production built binaries, but is necessary for the Debug binaries if we need to troubleshoot something? |
Yes, this PR should not make any difference with respect to the production SM binaries. The changes included in this changes are:
In summary, this PR can be safely merged (I have just rebased it, and it is ready now). |
…vel) (SeleniumHQ#12852) * [rust] Use anyhow crate to display backtrace in case of error * [rust] Include --backtrace argument to enable backtrace capture * [rust] Use --backtrace argument in test * [rust] Enable using RUST_BACKTRACE to capture backtrace as well * [rust] Remove --backtrace (display backtrace when error is available at DEBUG level) * [rust] Include debug info in release artifact and enable backtrace by default * Revert "[rust] Include debug info in release artifact and enable backtrace by default" This reverts commit aa57f2a. * [rust] Remove backtrace for warning message * [rust] Remove --backtrace from test * [rust] Fix problems after rebasing * [rust] Update bazel lock file * [rust] Remove old download browser function in edge module
Description
This PR uses the anyhow crate to display backtrace in case of error.
Motivation and Context
The standard Rust library for error types does not include a stack trace. This fact can sometimes be problematic for troubleshooting, especially when some standard error (e.g., due to the file system) happens in the internal logic of Selenium Manager. Some typical example is as follows:
There is currently a reported issue in which that error happens. And in that case, we don't know in which code line that error is happening.
To ease the troubleshooting procedure in future issues, this PR includes the anyhow crate for handling errors in all the Selenium Manager Rust logic.
Thanks to this crate, we can capture the backtrace, and with that, we can discover in which line of the Rust code the error happened. To enable the backtrace capture, we set the standard Rust environment variable
RUST_BACKTRACE
to1
.For example, consider the following forced error:
Selenium Manager finished due to a bad name in the specified browser. But if
RUST_BACKTRACE
is set to1
, in addition, we have the complete backtrace in the output:The backtrace is also captured in the JSON output, which is the relevant one for the integration in the bindings:
Types of changes
Checklist