bensheldon/good_job · error · ArgumentError

Capsule#restart cannot be called with a timeout of nil

Error message

Capsule#restart cannot be called with a timeout of nil

What it means

Error "Capsule#restart cannot be called with a timeout of nil" thrown in bensheldon/good_job.

Source

Thrown at lib/good_job/capsule.rb:72

    # Shut down the thread pool executors.
    # @param timeout [nil, Numeric, NONE] Seconds to wait for active threads.
    #   * +-1+ will wait for all active threads to complete.
    #   * +0+ will interrupt active threads.
    #   * +N+ will wait at most N seconds and then interrupt active threads.
    #   * +nil+ will trigger a shutdown but not wait for it to complete.
    # @return [void]
    def shutdown(timeout: NONE)
      timeout = configuration.shutdown_timeout if timeout == NONE
      GoodJob._shutdown_all([@notifier, @poller, @multi_scheduler, @cron_manager].compact, after: [@shared_executor], timeout: timeout)
      @startable = false
      @started_at = nil
    end

    # Shutdown and then start the capsule again.
    # @param timeout [Numeric, NONE] Seconds to wait for active threads.
    # @return [void]
    def restart(timeout: NONE)
      raise ArgumentError, "Capsule#restart cannot be called with a timeout of nil" if timeout.nil?

      shutdown(timeout: timeout)
      start(force: true)
    end

    # @return [Boolean] Whether the capsule is currently running.
    def running?
      @started_at.present?
    end

    # @return [Boolean] Whether the capsule has been shutdown.
    def shutdown?
      [@notifier, @poller, @multi_scheduler, @cron_manager].compact.all?(&:shutdown?)
    end

    # @param duration [nil, Numeric] Length of idleness to check for (in seconds).
    # @return [Boolean] Whether the capsule is idle
    def idle?(duration = nil)

View on GitHub (pinned to 5fcde48f87)

Solutions

  1. Provide a numeric timeout when calling Capsule#restart.
  2. Call restart with a timeout value in seconds.

Example fix

capsule.restart(timeout: 5)

When it happens

Trigger: Thrown at lib/good_job/capsule.rb:72 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of bensheldon/good_job@5fcde48f87 (2026-08-23). Data as JSON: /api/errors/f77b7311c1fce3d1. Report an issue: GitHub.