Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: Raise error when calling batch.jobs more than once when defining the batch? #6293

Closed
stevenou opened this issue May 15, 2024 · 2 comments

Comments

@stevenou
Copy link

As clearly stated in the documentation,

Note that it is not safe to call batch.jobs more than once when defining the batch.

https://github.com/sidekiq/sidekiq/wiki/Batches

That being said, I have been bitten a few times by accidentally calling batch.jobs more than once. I'm wondering if it's possible to raise an error when a user does this so the mistake can be caught and fixed sooner? When I accidentally do this, I end up with a batch that never finishes because there are non-existent pending jobs.

Not sure if this makes sense or not, but would like to hear your thoughts.

Thanks!

@mperham
Copy link
Collaborator

mperham commented May 15, 2024

I've tried to do this before, it was tricky to determine whether it is safe or not. Additionally I realized it could be better to retain backwards compatibility with racy code rather than breaking people's apps and forcing them to rework their batch code.

@stevenou
Copy link
Author

Understood on the first point.

On the second point, I'd imagine it would be similar to Sidekiq.strict_args! which makes raising an exception optional/configurable.

@mperham mperham closed this as completed Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants