Skip to content

[Bug] Potential issue using runtime Sorbet and handlers #292

@cretz

Description

@cretz

What are you really trying to do?

Describe the bug

User getting error like:

/Users/someuser/.dev/gem/somehash/gems/temporalio-0.4.0-arm64-darwin/lib/temporalio/workflow/definition.rb:287:in 'Temporalio::Workflow::Definition.singleton_method_added': Attempting to override Temporal-defined class definition method (RuntimeError)
	from /Users/someuser/.dev/gem/somehash/gems/sorbet-runtime-0.5.12164/lib/types/private/methods/_methods.rb:555:in 'T::Private::Methods::SingletonMethodHooks#singleton_method_added'
	from /Users/someuser/.dev/gem/somehash/gems/sorbet-runtime-0.5.12164/lib/types/private/class_utils.rb:82:in 'Module#define_method'
	from /Users/someuser/.dev/gem/somehash/gems/sorbet-runtime-0.5.12164/lib/types/private/class_utils.rb:82:in 'block in T::Private::ClassUtils.def_with_visibility'
	from /Users/someuser/.dev/gem/somehash/gems/sorbet-runtime-0.5.12164/lib/types/private/class_utils.rb:73:in 'Module#module_exec'
	from /Users/someuser/.dev/gem/somehash/gems/sorbet-runtime-0.5.12164/lib/types/private/class_utils.rb:73:in 'T::Private::ClassUtils.def_with_visibility'
	from /Users/someuser/.dev/gem/somehash/gems/sorbet-runtime-0.5.12164/lib/types/private/methods/call_validation.rb:31:in 'block (2 levels) in T::Private::Methods::CallValidation.wrap_method_if_needed'
	from /Users/someuser/.dev/gem/somehash/gems/sorbet-runtime-0.5.12164/lib/types/private/decl_state.rb:25:in 'T::Private::DeclState#without_on_method_added'
	from /Users/someuser/.dev/gem/somehash/gems/sorbet-runtime-0.5.12164/lib/types/private/methods/call_validation.rb:30:in 'block in T::Private::Methods::CallValidation.wrap_method_if_needed'
	from /Users/someuser/.dev/gem/somehash/gems/sorbet-runtime-0.5.12164/lib/types/configuration.rb:533:in 'T::Configuration.without_ruby_warnings'
	from /Users/someuser/.dev/gem/somehash/gems/sorbet-runtime-0.5.12164/lib/types/private/methods/call_validation.rb:28:in 'T::Private::Methods::CallValidation.wrap_method_if_needed'
	from /Users/someuser/.dev/gem/somehash/gems/sorbet-runtime-0.5.12164/lib/types/private/methods/_methods.rb:411:in 'T::Private::Methods.unwrap_method'
	from /Users/someuser/.dev/gem/somehash/gems/sorbet-runtime-0.5.12164/lib/types/private/methods/_methods.rb:353:in 'T::Private::Methods.run_sig'
	from /Users/someuser/.dev/gem/somehash/gems/sorbet-runtime-0.5.12164/lib/types/private/methods/_methods.rb:248:in 'block in T::Private::Methods._on_method_added'
	from /Users/someuser/.dev/gem/somehash/gems/sorbet-runtime-0.5.12164/lib/types/private/methods/_methods.rb:449:in 'T::Private::Methods.run_sig_block_for_key'
	from /Users/someuser/.dev/gem/somehash/gems/sorbet-runtime-0.5.12164/lib/types/private/methods/_methods.rb:469:in 'block in T::Private::Methods.run_all_sig_blocks'
	from <internal:kernel>:168:in 'Kernel#loop'
	from /Users/someuser/.dev/gem/somehash/gems/sorbet-runtime-0.5.12164/lib/types/private/methods/_methods.rb:466:in 'T::Private::Methods.run_all_sig_blocks'
	from /Users/someuser/.dev/gem/somehash/gems/sorbet-runtime-0.5.12164/lib/types/utils.rb:85:in 'T::Utils.run_all_sig_blocks'

Somehow Sorbet seems to be creating a duplicate singleton method after (or when) we do. First, we need to replicate, which can probably be done with a simple signal like:

    sig { void }
    workflow_signal
    def activate_program
      # do something
    end

Understand why Sorbet is adding singleton methods to our class and if we can avoid it. Second, solve. Worst case scenario we may have to detect the situation where it's Sorbet adding a method and ignore it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions