open-formulieren / open-forms-sdk

A Javascript SDK for Open Forms
https://open-forms.readthedocs.io/en/stable/developers/sdk/index.html
Other
2 stars 6 forks source link

[open-formulieren/open-forms#4082] Fix duplicate creation of submissions #669

Closed Viicos closed 4 months ago

Viicos commented 4 months ago

Fixes open-formulieren/open-forms#4082

A race condition is happening and the useAsync hook is being called three times, and onFormStart would be called every time as onFormStartCalledRef wasn't set to true by the first called in time.

This only happens when using a login button, as the useAync hook is watching on the _start query parameter, and a change to this query parameter seems to trigger the hook three times for some reason.

(This doesn't happen with the "Begin form" button as in this case, the onFormStart function is called directly).

codecov[bot] commented 4 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 63.88%. Comparing base (e6a0880) to head (74bf9da).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #669 +/- ## ========================================== + Coverage 63.15% 63.88% +0.73% ========================================== Files 93 93 Lines 1642 1642 Branches 427 427 ========================================== + Hits 1037 1049 +12 + Misses 605 593 -12 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.