You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.
While testing Vanity (2.2.7) behavior in situation when Redis is down, we discovered that the following code Vanity.playground.participant_info(vanity_identity) throws an error NoMethodError (undefined method to_i' for true:TrueClass):` with no stack trace in Vanity code.
We traced how the error and found a workaround, but it probably makes sense to get fixed on Vanity side.
Vanity.configuredo |config|
config.failover_on_datastore_error=trueconfig.on_datastore_error=Proc.newdo |error,klass,method,arguments|
Rails.logger.error("Vanity error: #{error}. Called by #{klass.inspect}, method #{method.inspect} with arguments #{arguments}")endend
If we add nil as return value of on_datastore_error callback, everything works ok. Without it, Rails.logger.error seems to return true which is being returned from ab_assigned and breaks participants_info method logic.
We are not sure how it should be fixed, probably documentation just should mention returning nil.
The text was updated successfully, but these errors were encountered:
I wonder if we should instead be explicitly returning nil from call_redis_with_failover in the case of an exception? For example,
def call_redis_with_failover(*arguments)
calling_method = caller[0][/`.*'/][1..-2]
begin
yield
rescue => e
if Vanity.configuration.failover_on_datastore_error
Vanity.configuration.on_datastore_error.call(e, self.class, calling_method, arguments)
return nil # don't implicitly return the value returned by `on_datastore_error`
else
raise e
end
end
end
Another approach is to have a default_result parameter with default value as nil to give other methods calling call_redis_with_failover possibility to provide default return value to have more flexibility (some method would like to have [] or {} to be returned instead of nil). Though not sure whether this is needed and probably simple return nil would suffice.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
While testing Vanity (2.2.7) behavior in situation when Redis is down, we discovered that the following code
Vanity.playground.participant_info(vanity_identity)
throws an errorNoMethodError (undefined method
to_i' for true:TrueClass):` with no stack trace in Vanity code.We traced how the error and found a workaround, but it probably makes sense to get fixed on Vanity side.
Looks like when the connection to Redis is down, ab_assigned returns true instead of nil or 0, which is being converted to int
So it either return alternative.id or nil. But we get true, how come? Lets check call_redis_with_failover method
It either rethrows exception, or return blocks return value, or... it returns result of on_datastore_error callback.
We are not sure how it should be fixed, probably documentation just should mention returning nil.
The text was updated successfully, but these errors were encountered: