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

🐛 Fix potential race condition on WebKit #585

Closed Viicos closed 12 months ago

Viicos commented 12 months ago

Fixes https://github.com/open-formulieren/open-forms/issues/3572.

The race condition happens after onFormIOChange is called a first time:

onFormIOChange will schedule a call to evaluateFormLogic that will in turn dispatch BLOCK_SUBMISSION (thus setting canSubmit=false). Logic check is performed, and LOGIC_CHECK_DONE is about to be dispatched (which will set canSubmit to true if the logic check allows it).

For some reason, having a colored HTML element triggers onFormIOChange at this specific time. On Firefox, LOGIC_CHECK_DONE was fired in time so it had time to set canSubmit to true again (as you can see logicChecking is false when this onFormIOChange call happens). However, WebKit seems to be to slow and onFormIOChange is called before LOGIC_CHECK_DONE is fired.

For now my fix is to return if we are still formChecking, but ideally a more robust solution should be found (e.g. a queue handling all the form change events?)

codecov[bot] commented 12 months ago

Codecov Report

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

Comparison is base (0fefecd) 71.25% compared to head (fe01a61) 65.20%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #585 +/- ## ========================================== - Coverage 71.25% 65.20% -6.06% ========================================== Files 212 194 -18 Lines 4300 4144 -156 Branches 1163 1122 -41 ========================================== - Hits 3064 2702 -362 - Misses 1201 1442 +241 + Partials 35 0 -35 ``` | [Files](https://app.codecov.io/gh/open-formulieren/open-forms-sdk/pull/585?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-formulieren) | Coverage Δ | | |---|---|---| | [src/components/FormStep/index.js](https://app.codecov.io/gh/open-formulieren/open-forms-sdk/pull/585?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-formulieren#diff-c3JjL2NvbXBvbmVudHMvRm9ybVN0ZXAvaW5kZXguanM=) | `37.39% <100.00%> (+0.55%)` | :arrow_up: | ... and [75 files with indirect coverage changes](https://app.codecov.io/gh/open-formulieren/open-forms-sdk/pull/585/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-formulieren)

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

sergei-maertens commented 12 months ago

Backports: b646d30e2bbd0d40e663fe198dbf8bdeda8869eb, 5d34139357b3d66b3f37378bccdabff3dfca7279 and 0f3462e3c963a433346fee044315d71a29fbc505