Skip to content

Commit

Permalink
Fix thread safety error with handlers
Browse files Browse the repository at this point in the history
`process` sets instance variables that get used in the hander so handler instances can not be shared across requests.
  • Loading branch information
albus522 committed Jul 31, 2023
1 parent b213d2a commit 7979b71
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/twirp/rails/dispatcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Twirp
module Rails
class Dispatcher
def initialize(service_class)
@service_handler = "#{service_class.service_name}Handler".constantize.new
@service_handler = "#{service_class.service_name}Handler".constantize
end

def respond_to_missing?(method, *)
Expand All @@ -14,7 +14,7 @@ def respond_to_missing?(method, *)
def method_missing(name, *args)
request = args[0]
env = args[1]
@service_handler.process(name, request, env)
@service_handler.new.process(name, request, env)
end
end
end
Expand Down

0 comments on commit 7979b71

Please sign in to comment.