[6.x] Fix save button hanging forever when a save hook fails - #15194
Merged
Conversation
BeforeSaveHooks and AfterSaveHooks only wired up the fulfilment path, so a rejecting or throwing saving/saved hook left the promise unsettled. The pipeline stalled, saving state stayed true, and the form locked up with no diagnostic beyond a console message. Propagate the rejection, and reset the saving state for any error rather than only PipelineStopped, so a rejection doesn't just become a different hang. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes a bug where the Save button could spin forever, locking the form until a page reload — losing unsaved work.
BeforeSaveHooksandAfterSaveHookswrapped the hook run in a promise but only wired up the fulfilment path. If asavingorsavedhook rejected — or threw, which becomes a rejection — nothing ever calledresolveorreject, so the promise never settled. The pipeline stalled mid-flight,Finishnever ran, and the saving state stayedtrue. The only sign anything went wrong was an unhandled rejection in the console.Since
savingandsavedare public extension points, a single throwing hook in an addon or in a site's own CP JS takes out saving entirely for that form.The rejection is now propagated.
Pipeline.through()also resets the saving state for any error, not justPipelineStopped— otherwise propagating the rejection would only have converted the hang into a different one.Also added the missing
.catchto the user publish form, the one publish form with no rejection handler at all.To reproduce on
6.x: registerStatamic.$hooks.on('entry.saving', (resolve, reject) => reject(new Error('boom')))in your CP JS, then save an entry.