{"record":{"id":"918454f1aa0569b3","repo":"ankane/searchkick","slug":"wait-only-available-in-async-mode","errorCode":null,"errorMessage":"wait only available in :async mode","messagePattern":"wait only available in :async mode","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/searchkick/index.rb","lineNumber":364,"sourceCode":"    end\n\n    def import_before_promotion(index, relation, **import_options)\n      index.import_scope(relation, **import_options)\n    end\n\n    def reindex_records(object, mode: nil, refresh: false, **options)\n      mode ||= Searchkick.callbacks_value || @options[:callbacks] || :inline\n      mode = :inline if mode == :bulk\n\n      result = RecordIndexer.new(self).reindex(object, mode: mode, full: false, **options)\n      self.refresh if refresh\n      result\n    end\n\n    # https://gist.github.com/jarosan/3124884\n    # https://www.elastic.co/blog/changing-mapping-with-zero-downtime/\n    def full_reindex(relation, import: true, resume: false, retain: false, mode: nil, refresh_interval: nil, scope: nil, wait: nil, job_options: nil)\n      raise ArgumentError, \"wait only available in :async mode\" if !wait.nil? && mode != :async\n      raise ArgumentError, \"Full reindex does not support :queue mode - use :async mode instead\" if mode == :queue\n\n      if resume\n        index_name = all_indices.sort.last\n        raise Error, \"No index to resume\" unless index_name\n        index = Index.new(index_name, @options)\n      else\n        clean_indices unless retain\n\n        index_options = relation.searchkick_index_options\n        index_options.deep_merge!(settings: {index: {refresh_interval: refresh_interval}}) if refresh_interval\n        index = create_index(index_options: index_options)\n      end\n\n      import_options = {\n        mode: (mode || :inline),\n        full: true,\n        resume: resume,","sourceCodeStart":346,"sourceCodeEnd":382,"githubUrl":"https://github.com/ankane/searchkick/blob/93e901a75b11a25101668a616e006b158251b16e/lib/searchkick/index.rb#L346-L382","documentation":"mode: :async reindexing enqueues jobs through Active Job (ReindexV2Job, BulkReindexJob, ProcessBatchJob). RecordIndexer checks defined?(ActiveJob) and raises Error 'Active Job not found' when it is not loaded - typically when Searchkick is used outside full Rails or in an app that skipped Active Job.","triggerScenarios":"Product.reindex(mode: :async) from a standalone Ruby script, Sinatra app, or a boot path where Active Job was never required; a Gemfile without rails/activejob while code still uses :async mode.","commonSituations":"Adding background reindexing in a non-Rails project; a test harness that boots only activerecord; a Rails app generated with --skip-active-job; running rake tasks before the Rails environment is loaded.","solutions":["Load Active Job and pick a queue adapter: require 'active_job' and set config.active_job.queue_adapter = :sidekiq (or :inline for scripts)","If jobs are not an option, use mode: :inline (same process) or mode: :queue with Redis","In Rails, ensure the full application environment is booted (rails runner, app tasks) before calling reindex(mode: :async)"],"exampleFix":"# before\nProduct.reindex(mode: :async) # plain ruby / Sinatra, no ActiveJob loaded\n# => Searchkick::Error: Active Job not found\n\n# after\nrequire 'active_job'\nActiveJob::Base.queue_adapter = :inline # or :async / :sidekiq\nProduct.reindex(mode: :async)","handlingStrategy":"validation","validationCode":"def reindex_async?(mode)\n  return false unless mode == :async\n  raise 'Active Job not available' unless defined?(ActiveJob)\n  true\nend\n\nmode = reindex_async?(:async) ? :async : :inline\nProduct.reindex(mode: mode)","typeGuard":null,"tryCatchPattern":"begin\n  Product.reindex(mode: :async)\nrescue Searchkick::Error\n  # no ActiveJob in this context - degrade to inline\n  Product.reindex(mode: :inline)\nend","preventionTips":["Boot-check dependencies: fail fast at startup if :async mode is configured but ActiveJob is missing","In non-Rails scripts, require 'active_job' and set a queue adapter before any reindex","Prefer mode: :queue (Redis) where ActiveJob is unavailable"],"tags":["searchkick","reindex","activejob","missing-dependency","async"],"backgroundTag":"missing-dependency","analyzedSha":"93e901a75b11a25101668a616e006b158251b16e","analyzedAt":"2026-08-21T19:06:23.767Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}