Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .agents/codebase-insights.txt
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
No insights yet. Please add content here and remove this line.
When tracing scripts with the pure Ruby recorder, avoid including the
`RubyRecorder` instance (or its `TraceRecord`) among the inspected local
variables. Otherwise the serializer will descend into the tracer's own
state which quickly explodes in size and appears as infinite recursion.
`load_variables` filters these objects out.
23 changes: 14 additions & 9 deletions gems/codetracer-pure-ruby-recorder/lib/trace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,21 @@ def deactivate

private

# Collect local variables from the current +binding+. Variables that refer to
# the tracer itself or the trace record are ignored to avoid recursively
# serialising the internal state of the tracer.
def load_variables(binding)
if !binding.nil?
# $stdout.write binding.local_variables
binding.local_variables.map do |name|
v = binding.local_variable_get(name)
out = to_value(v)
[name, out]
end
else
[]
return [] if binding.nil?

binding.local_variables.filter_map do |name|
v = binding.local_variable_get(name)

next if v.equal?(self) || v.equal?(@record)
next if defined?(RubyRecorder) && v.is_a?(RubyRecorder)
next if defined?(TraceRecord) && v.is_a?(TraceRecord)

out = to_value(v)
[name, out]
end
end
end
Expand Down
Loading