Skip to content

Frozen/Deadlocked Ruby thread instead of NoMethodError #357

@danielricecodes

Description

@danielricecodes

I am not sure if this is a known issue or not, but when yielding to a block w/ 2 arguments (e.g. arity = 2) its possible to freeze your app / test code. The following coding mistake should have resulted in a NoMethodError. Instead, Ruby freezes and I have to kill -9 the thread.

The following will freeze my app in its tracks. It should throw a NoMethodError.

module Entities
  class Invoice < Grape::Entity
    expose :id
    expose(:foo) do |object, options|
      bar.to_s
    end
  end
end

The only mistake above was not referencing object first.

module Entities
  class Invoice < Grape::Entity
    expose :id
    expose(:foo) do |object, options|
      object.bar.to_s
    end
  end
end

I'm happy to try to fix this - but first I'm asking if anyone else has noticed this or maybe there is already a PR for something similar?

Versions

Ruby 2.7.3
Rails 6.1
grape (1.5.3)
grape-entity (0.9.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions