bensheldon/good_job · error · ArgumentError

Scheduler#restart cannot be called with a timeout of nil

Error message

Scheduler#restart cannot be called with a timeout of nil

What it means

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

Source

Thrown at lib/good_job/scheduler.rb:125

        end

        if executor.shuttingdown? && timeout
          executor_wait = timeout.negative? ? nil : timeout
          return if executor.wait_for_termination(executor_wait)

          instrument("scheduler_shutdown_kill", { active_job_ids: @performer.performing_active_job_ids.to_a })
          executor.kill
          executor.wait_for_termination
        end
      end
    end

    # Restart the Scheduler.
    # When shutdown, start; or shutdown and start.
    # @param timeout [Numeric] Seconds to wait for actively executing jobs to finish; shares same values as {#shutdown}.
    # @return [void]
    def restart(timeout: -1)
      raise ArgumentError, "Scheduler#restart cannot be called with a timeout of nil" if timeout.nil?

      instrument("scheduler_restart_pools") do
        shutdown(timeout: timeout)
        @performer.reset_stats
        create_executor
        warm_cache
      end
    end

    # Wakes a thread to allow the performer to execute a task.
    # @param state [Hash, nil] Contextual information for the performer. See {JobPerformer#next?}.
    # @return [Boolean, nil] Whether work was started.
    #   * +nil+ if the scheduler is unable to take new work, for example if the thread pool is shut down or at capacity.
    #   * +true+ if the performer started executing work.
    #   * +false+ if the performer decides not to attempt to execute a task based on the +state+ that is passed to it.
    def create_thread(state = nil)
      return nil unless executor.running?

View on GitHub (pinned to 5fcde48f87)

Solutions

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

Example fix

scheduler.restart(timeout: 5)

When it happens

Trigger: Thrown at lib/good_job/scheduler.rb:125 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/17ffd29ae28e650a. Report an issue: GitHub.