Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please require the Numeric after NumericSecond for scope visibility #812

Open
mensfeld opened this issue Jan 15, 2021 · 0 comments
Open

Comments

@mensfeld
Copy link

mensfeld commented Jan 15, 2021

Hey there,

First of all, thank you for this amazing gem.

We have one problem related to our edge-case of working with Bundler Whenever and a background thread.

Due to the fact, that numeric.rb patches the Numeric, it expects the visibility of the NumericSeconds. What that means is, that in a rare case where you would have code running prior to loading whenever and you would require whenever, you end up with the following exception:

uninitialized constant Whenever

Would you be so kind (I can do it) and swap the loading order of those two classes?

ref https://github.com/javan/whenever/blob/master/lib/whenever.rb#L1
ref https://github.com/javan/whenever/blob/master/lib/whenever/numeric.rb#L3

repro (you need to start it couple of times and wait as it takes Ruby a while to jump with the require in between those executions and sometimes it will just hang forever):

Thread.new do
  while true
    begin
      1.respond_to?(:elo)
      sleep 0.00001
    rescue => e
      p e
    end
  end
end

sleep 0.1

require 'whenever'

end effect:

#<NameError: uninitialized constant Whenever>
#<NameError: uninitialized constant Whenever>
#<NameError: uninitialized constant Whenever>
#<NameError: uninitialized constant Whenever>
#<NameError: uninitialized constant Whenever>
#<NameError: uninitialized constant Whenever>
#<NameError: uninitialized constant Whenever>
#<NameError: uninitialized constant Whenever>
#<NameError: uninitialized constant Whenever>
#<NameError: uninitialized constant Whenever>
#<NameError: uninitialized constant Whenever>
#<NameError: uninitialized constant Whenever>
#<NameError: uninitialized constant Whenever>
#<NameError: uninitialized constant Whenever>
#<NameError: uninitialized constant Whenever>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant