Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Frozen/Deadlocked Ruby thread instead of NoMethodError

Open
#357 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
ruby
Domain
api

Research direction

Start by reproducing the provided Grape::Entity Invoice example with the two-argument expose block and the missing object receiver. Trace the expose block's yield and error handling to identify why the mistake deadlocks instead of raising NoMethodError. Done means the example raises NoMethodError and a regression test covers the behavior.

Written by the indexing model from the issue text.

Description

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)

Dominant language
Ruby
Stars
730
Forks
154
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ruby-grape/grape-entity

All issues in ruby-grape/grape-entity

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.