Skip to content

Commit 177275a

Browse files
authored
Don't log full props or JS code (#1117)
Long props result in very long error messages
1 parent ea9d87a commit 177275a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/react_on_rails/prerender_error.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# rubocop:disable: Layout/IndentHeredoc
44
module ReactOnRails
55
class PrerenderError < ::ReactOnRails::Error
6+
MAX_ERROR_SNIPPET_TO_LOG = 1000
67
# TODO: Consider remove providing original `err` as already have access to `self.cause`
78
# http://blog.honeybadger.io/nested-errors-in-ruby-with-exception-cause/
89
attr_reader :component_name, :err, :props, :js_code, :console_messages
@@ -58,9 +59,9 @@ def calc_message(component_name, console_messages, err, js_code, props)
5859
end
5960
# rubocop:disable Layout/IndentHeredoc
6061
message << <<-MSG
61-
when prerendering #{component_name} with props: #{props}
62+
when prerendering #{component_name} with props (truncated): #{props.to_s[0, MAX_ERROR_SNIPPET_TO_LOG]}
6263
js_code was:
63-
#{js_code}
64+
#{js_code[0, MAX_ERROR_SNIPPET_TO_LOG]}
6465
MSG
6566
# rubocop:enable Layout/IndentHeredoc
6667

0 commit comments

Comments
 (0)