Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This attempts to address issues raised in #721
Introduction of beforeDelayEnqueue/afterDelayEnqueue plugin hooks, which are the retry plugin equivalent of beforeEnqueue/afterEnqueue
There were still issues surrounding the frozen args object, making it impossible to manipulate arg data when entering the beforePerform hook unless workarounds like
JSON.parse(JSON.stringify(this.args))
were used. To that end, the use ofObject.freeze
was replaced with Object.seal, and the reference tothis.args
from within a Plugin class was converted into a getter/setter that merges the value of reassigned args with the original args data, effectively preventing someone from adding/deleting a property from the args, but allowing them to modify properties that were in the original args. For example:I debated whether or not to surface the TypeError that's thrown when a sealed object is added to or removed from, but I felt that might cause confusion if you tried to assign a new property to args and it just never appeared. Having the TypeError bubble seems a bit better, so that's what it does. If you try to manipulate args in a way that's not permitted the error will be thrown and the job will fail, so you'd see that in the logs.
Sorry this took so long, @evantahler Holidays and such... Would love to get your feedback on this, I know the change to Object.freeze may seem a bit unexpected, but I'm hoping it will meet that middle ground goal of not breaking the issue raised in #99 while still permitting manipulation of args, at least within
beforePerform
. Perhaps I don't understand the ramifications of modifying args though.