Skip to content

Commit

Permalink
Better handling of empty stream response [#905]
Browse files Browse the repository at this point in the history
  • Loading branch information
byroot committed Jun 19, 2020
1 parent 5071cf2 commit 9fd381b
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions lib/redis.rb
Expand Up @@ -3427,9 +3427,7 @@ def method_missing(command, *args) # rubocop:disable Style/MissingRespondToMissi
private_constant :EMPTY_STREAM_RESPONSE

HashifyStreamEntries = lambda { |reply|
return [] if reply == EMPTY_STREAM_RESPONSE

reply.map do |entry_id, values|
reply.compact.map do |entry_id, values|
[entry_id, values.each_slice(2).to_h]
end
}
Expand Down

1 comment on commit 9fd381b

@taf2
Copy link

@taf2 taf2 commented on 9fd381b Dec 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this out in a live environment and quickly discovered this is not a fix.

calling compact does not guarantee values won't be nil.

  HashifyStreamEntries = lambda { |reply|
    reply.compact.map do |entry_id, values|
      [entry_id, values&.each_slice(2)&.to_h]
    end
  }

Please sign in to comment.