fix: guard debounced save against concurrent PUT calls#140
Merged
Conversation
Contributor
|
Seems that this PR contains more than just what is described? Seems like it also contains the changes from #137 ? It think it would be better to isolate the changes 😄 |
Add a `saving` flag to the debounced da-admin update handler in `bindState` so that if a prior PUT is still in flight when the debounced callback fires again, the second invocation is skipped rather than racing the first. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
e6e9fe6 to
c728a3b
Compare
35a0794 to
b2a51d5
Compare
Contributor
Author
|
@bosschaert yes, for some reason, the PR became cumulative. I isolate the change now, it only contains the PR specific changes only. |
bosschaert
approved these changes
May 11, 2026
adobe-bot
pushed a commit
that referenced
this pull request
May 11, 2026
## [1.2.5](v1.2.4...v1.2.5) (2026-05-11) ### Bug Fixes * guard debounced save against concurrent PUT calls ([#140](#140)) ([3eba8af](3eba8af))
Collaborator
|
🎉 This PR is included in version 1.2.5 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
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.
Problem
The debounced update handler in
persistence.bindStateis anasyncfunction called vialodash.debounce. If a PUT takes longer than the debounce window (2 s max-wait is 10 s), a second firing of the debounced callback will race the first — both simultaneously awaitingpersistence.putagainst da-admin. This can cause:Fix
Introduce a
savingboolean flag in the closure. If the flag is set when the debounced callback fires, the second invocation returns immediately instead of launching a concurrent PUT.Test
New test
Test concurrent save calls are guarded by saving flag:debounceas identity so the handler fires immediatelypersistence.putwith a 30 ms artificial delay and a concurrency counterPromise.all)maxConcurrentPuts === 1The test fails on the old code (observed 12 concurrent puts) and passes after this fix.
Part of series
This is PR 4/4 fixing the image-disappears-on-drag-and-drop bug:
If-Match: */ destructive 412 handler (fix: remove If-Match header and stop clearing storage on 412 #139)🤖 Generated with Claude Code