From 1b201b179772e17be237de87d969e309a77043e5 Mon Sep 17 00:00:00 2001 From: Matthew Fenelon Date: Thu, 12 Sep 2024 15:54:09 +0100 Subject: [PATCH] Fix tests to do with Fiber.current.storage.keys NoMethodError For ruby 3.3 and head on GitHub actions, the following error happens when accessing Fiber.current.storage.keys: ``` Failure/Error: fiber_storage = Fiber.current.storage.keys.each_with_object({}) do |key, memo| memo[key] = Fiber[key] end NoMethodError: undefined method 'keys' for nil ``` I don't think this should be happening as Fiber.current.storage is meant to always return a hash, even with Fiber.new(storage: nil) or Fiber.current.storage = nil. --- lib/graphiti/scope.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/graphiti/scope.rb b/lib/graphiti/scope.rb index 1dac31d4..bb9abfef 100644 --- a/lib/graphiti/scope.rb +++ b/lib/graphiti/scope.rb @@ -128,12 +128,12 @@ def future_with_fiber_locals(*args) thread_storage = Thread.current.keys.each_with_object({}) do |key, memo| memo[key] = Thread.current[key] end - fiber_storage = nil - if Fiber.current.respond_to?(:storage) - fiber_storage = Fiber.current.storage.keys.each_with_object({}) do |key, memo| - memo[key] = Fiber[key] + fiber_storage = + if Fiber.current.respond_to?(:storage) + Fiber.current&.storage&.keys&.each_with_object({}) do |key, memo| + memo[key] = Fiber[key] + end end - end Concurrent::Promises.future_on( self.class.global_thread_pool_executor, Thread.current.object_id, thread_storage, fiber_storage, *args