Skip to content

Commit 64be426

Browse files
committed
add comment
1 parent c8dd405 commit 64be426

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/hooks/app/helpers.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,12 @@ def parse_payload(raw_body, headers, symbolize: false)
7878
# @return [Object] An instance of the loaded handler class
7979
# @raise [StandardError] If handler cannot be found
8080
def load_handler(handler_class_name)
81-
# Get handler class from loaded plugins registry (boot-time loaded only)
81+
# Get handler class from loaded plugins registry (the registry is populated at boot time)
82+
# NOTE: We create a new instance per request (not reuse boot-time instances) because:
83+
# - Security: Prevents state pollution and information leakage between requests
84+
# - Thread Safety: Avoids race conditions from shared instance state
85+
# - Performance: Handler instantiation is fast; reusing instances provides minimal gain
86+
# - Memory: Allows garbage collection of short-lived objects (Ruby GC optimization)
8287
begin
8388
handler_class = Core::PluginLoader.get_handler_plugin(handler_class_name)
8489
return handler_class.new

0 commit comments

Comments
 (0)