-
Notifications
You must be signed in to change notification settings - Fork 336
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
Consider removing feature-gating of backtraces in 2.0 #1760
Comments
The backtraces add a lot of overhead at runtime which we don't want to have by default in Wasm, especially since error can be handled at runtime. They should be as lightweight as possible. In #1578 we'll remove a bunch of String allocations from errors for this reason.
Yeah, I see. I recommend using the StdError constructors instead of the structs. E.g. But strictly speaking you have a point here. Enabling an additional feature should not break any public interface. |
@webmaster128 Ah I didn't know about the runtime overhead. I guess then maybe it makes sense to keep it feature gated. The other option would be to make the feature default and disable it when compiling for production, although I suppose then some people might forget (although they should really be using rust-optimizer which could do it for them). Good tip on |
Looking at https://doc.rust-lang.org/stable/src/std/backtrace.rs.html#276-299 it seems like just adding them in all cases would be a noop. @chipshort WDYT about making all fields #[cfg(feature = "backtraces")]
backtrace: Backtrace, non-feature-gated and fill them either with a backtrace or |
So, the field would not be feature-gated, but if the feature is not set, we fill it with |
That's one option. The other way would be using |
Oh, that's a great idea. I didn't even think of that. Then you would never get them in wasm, but can enable them when using the env var when testing. |
Unfortunately we run into dtolnay/thiserror#236 / dtolnay/thiserror#204 when we do this. Any idea to be able to use thiserror together with backtrace fields? |
Please keep in mind that |
Good point. In this case I suggest some generic container field (Option or Box or something) with conditional contents and construction logic. |
This PR applied `parse_err` constructor, it reduces a feature inside `desmos-std-derive`. See: CosmWasm/cosmwasm#1760
Now that backtraces API is stabilized since Rust 1.65.0 (2022-11-03), I would like to raise the idea of removing the feature-gating of backtraces. Backtraces are very helpful in debugging contract errors, but unfortunately the fact that they are currently feature-gated means that most packages that depend on
cosmwasm-std
do not support them and constructStdError
s without thebacktrace
field (one example here), which means that if you try to depend on such a package and enable the backtraces feature, compilation will fail since dependencies share features. If we remove the feature-gating then all packages depending oncosmwasm-std
will require to add backtraces when constructingStdError
s, so this would be a breaking change. Something to consider for the next major version.The text was updated successfully, but these errors were encountered: