From 33c03aa822da9ebe0a7a8c0f4ba65c982921f568 Mon Sep 17 00:00:00 2001 From: Michael Go Date: Mon, 24 Nov 2025 15:22:12 -0400 Subject: [PATCH 1/2] fix parsing memory sample bake task --- bake/async/container/supervisor.rb | 8 +++++++- lib/async/container/supervisor/worker.rb | 2 +- test/async/container/supervisor.rb | 4 ++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/bake/async/container/supervisor.rb b/bake/async/container/supervisor.rb index 3fa462d..18db5c0 100644 --- a/bake/async/container/supervisor.rb +++ b/bake/async/container/supervisor.rb @@ -44,7 +44,13 @@ def memory_sample(duration: 10, connection_id:) operation = {do: :memory_sample, duration: duration} # Use the forward operation to proxy the request to a worker: - return connection.call(do: :forward, operation: operation, connection_id: connection_id) + data = connection.call(do: :forward, operation: operation, connection_id: connection_id) + + if data && data.key?(:data) + JSON.parse(data[:data], symbolize_names: true) + else + data + end end end diff --git a/lib/async/container/supervisor/worker.rb b/lib/async/container/supervisor/worker.rb index 3c3ebde..31f9508 100644 --- a/lib/async/container/supervisor/worker.rb +++ b/lib/async/container/supervisor/worker.rb @@ -117,7 +117,7 @@ def do_memory_sample(call) report = sampler.report dump(call) do |file| - file.puts(report.to_s) + file.puts(report.to_json) end ensure GC.start diff --git a/test/async/container/supervisor.rb b/test/async/container/supervisor.rb index a331434..a845176 100644 --- a/test/async/container/supervisor.rb +++ b/test/async/container/supervisor.rb @@ -117,6 +117,10 @@ def reader_target.dispatch(call); end # The result should contain a report expect(result).to have_keys(:data) + + report = JSON.parse(result[:data], symbolize_names: true) + + expect(report).to have_keys(:total_allocated, :total_retained, :aggregates) ensure worker_task&.stop end From 09e13d925cbb0e56f5cc0c692a49e7c6e4511f64 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Fri, 28 Nov 2025 11:04:43 +1300 Subject: [PATCH 2/2] Apply suggestion from @samuel-williams-shopify --- bake/async/container/supervisor.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bake/async/container/supervisor.rb b/bake/async/container/supervisor.rb index 18db5c0..de03cee 100644 --- a/bake/async/container/supervisor.rb +++ b/bake/async/container/supervisor.rb @@ -44,12 +44,12 @@ def memory_sample(duration: 10, connection_id:) operation = {do: :memory_sample, duration: duration} # Use the forward operation to proxy the request to a worker: - data = connection.call(do: :forward, operation: operation, connection_id: connection_id) + response = connection.call(do: :forward, operation: operation, connection_id: connection_id) - if data && data.key?(:data) - JSON.parse(data[:data], symbolize_names: true) + if response && response.key?(:data) + JSON.parse(response[:data], symbolize_names: true) else - data + response end end end