Skip to content

Commit

Permalink
Fix tests to do with Fiber.current.storage.keys NoMethodError
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MattFenelon committed Sep 12, 2024
1 parent d8c3b4b commit 1b201b1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/graphiti/scope.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1b201b1

Please sign in to comment.