-
Notifications
You must be signed in to change notification settings - Fork 22.2k
Closed
Labels
Description
Steps to reproduce
- Set a value during seeding in a class that inherits from
ActiveSupport::CurrentAttributes - Run code that enqueues a job via
ActiveJob(e.g. uploading a file viaActiveStorage) - Note that the value from step 1 is cleared
Because the database is seeded with the inline adapter, jobs run inline in seeding. When the job is run, the executor resets all current attributes. Here's a commit that exhibits the issue.
In my app, I'm iterating over customers and seeding a logo for each then seeding users for each. The iteration uses Current.set(customer: customer) { yield }, and within the yield we attach a logo. After that logo is attached, Current.customer is reset to nil because ActiveStorage::AnalyzeJob.perform_later(self) runs .
Expected behavior
Jobs run inline should not clear CurrentAttributes.
Actual behavior
CurrentAttributes are cleared.
System configuration
Rails version: Rails 6.0.0
Ruby version: ruby 2.6.5p114
Reactions are currently unavailable